- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我目前正在尝试用远程数据填充剑道网格。Kendo 有自己的函数来获取数据,但我想使用我创建的 Angular 工厂。
所以我有一个工厂,它有一个函数“getSkills”。此函数从我的 api 获取所有技能对象。
angular.module('MyApp').factory('Factory', function ($resource) {
return $resource('/api/v1/skills/', { },
{
getSkills: { method: 'GET', isArray: true }
});
});
在我的 angular SkillController 中,我将这些获取的技能放在一个范围变量中。
$scope.skills = SkillFactory.getSkills();
我在这里初始化剑道网格:
$scope.gridOptions = {
dataSource: {
data: $scope.skills,
schema: {
model: {
fields: {
ID: { type: "number" },
Name: { type: "string" },
CreatedBy: { type: "number" },
CreatedDate: { type: "string" },
EditedBy: { type: "number" },
EditedDate: { type: "string" },
InUse: { type: "boolean" }
}
}
},
pageSize: 20
},
scrollable: true,
sortable: true,
filterable: true,
pageable: {
input: true,
numeric: false
},
selectable: true,
columns: [
{ field: "Name", title: "skillname", width: "130px" }
]
};
大多数时候,ajax 回调比 kendo 网格的初始化慢。然后它将显示一个空表,因为表的数据未绑定(bind)到 Angular $scope.skills 变量。
我到处搜索,但我无法弄清楚如何在初始化中为数据属性使用自定义函数,或者如何将范围变量绑定(bind)到表。
如有任何帮助,我们将不胜感激!
最佳答案
我找到了一个更简单的解决方案:在我的例子中,$scope.regs 定义了使用 Angular 从服务器 REST 服务更新的数据$resource 使用“AppService”公开。此服务定义为:
var registrationServices = angular.module('registrationServices', ['ngResource']);
registrationServices.factory('AppService', ['$resource',
function($resource) {
return $resource('rest/registrations');
}]);
我将 k-auto-bind = "false"设置为 HTML 中的网格定义:
<div id="form-item">
<label for="appId" class="info">AppId:</label>
<input id="appId" ng-model="searchAppId">
<button id="search" class="k-button" ng-click="doSearch()" >Search</button>
</div>
<div kendo-grid k-data-source="registrations" k-selectable="'row'"
k-pageable='{ "refresh": true, "pageSizes": true }'
k-columns="registrationsColumns"
k-sortable="true" k-groupable="true" k-filterable="true"
k-on-change="selectedItem = data"
k-auto-bind="false" >
</div>
我没有使用“data”属性绑定(bind) Kendo 网格数据源,而是使用“transport”和“read”定义为函数,类似这样:
$scope.regs;
$scope.registrations = new kendo.data.DataSource({
transport: {
read: function(options) {
options.success($scope.regs);
}
},
schema: {
model: {
fields: {
registrationId: {type: "number"},
clientFullName: {type: "string"},
registrationDate2: {type: "number"},
registrationDate: {type: "date"}
}
}
},
pageSize: 5,
serverPaging: true,
serverFiltering: true,
serverSorting: true
});
$scope.registrationsColumns = [{"field": "registrationId", "title": "Id"},
{"field": "clientFullName", "title": "Name"},
{"field": "registrationDate",
"title": "Registration Date",
format: "{0:dd/MM/yyyy}",
filterable: {ui: dateFilter, extra: "false"}
}
];
....
然后,当我想刷新网格中的数据时,我使用 Angular $resource 进行回调。 :
$scope.doSearch = function() {
$scope.regs = AppService.query({"regId": $scope.searchAppId}, function(result) {
$scope.registrations.read();
});
};
它有效。此解决方案的另一个优点是,您不必将网格创建移动到 Java Script 代码,它可以保留在 HTML 中。
关于javascript - 给剑道数据源一个 Angular 范围变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19289854/
我有两个剑道 DatePickers 来选择工作的开始和结束日期。作业由多个任务组成,其中包含自己的完成日期(任务在网格中列出,每条记录使用 kendo DatePicker 选择完成日期) 当用户设
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
kendo ui 网格不支持卡住列。如果有人可以帮助定制剑道网格卡住列的脚本,将不胜感激。有什么建议么? 列: [ ] 最佳答案 Kendo UI Grid 将在下一个正式版本 - 2014 年第一季
有谁知道如果更改事件在剑道窗口内,为什么更改事件不触发? 我正在使用 knockout kendo.js。 最佳答案 For Change Event Firing Here is sample
使用剑道 Angular 下拉菜单,我可以设置数据和默认值,但由于某种原因,稍后从可用选项中设置值不起作用? 我有一个基本数据模型 {id:x, value:y}。初始化下拉列表后设置值的正确代码是什
有人成功获得了可与自动完成功能配合使用的模板吗? 我在 site 上试过这个例子: template: '' + '#: data.ContactName ##: data.CompanyName #
我想知道是否有办法让我创建一个“kendo”复选框?我知道没有小部件,但也许有一个我可以应用的类,就像我对文本框所做的那样 as suggested here或者像我在这里所做的那样将复选框缩放到更大
我需要一个 Kendo-UI 网格的下拉列表,并遇到了这个示例: http://codepen.io/jordanilchev/pen/cnkih?editors=001 但在这个例子中,下拉菜单的键
我已将 Kendo 网格上的字体大小更改为 11,这样一来,日期选择器文本框上的日历图标在底部被截断了。当您使用以下代码将鼠标悬停在图标上时,我可以使用 margin-top 将图标向上移动,但是我无
我有一个带有占位符数据的 Kendo UI 日期选择器。这是HTML: 这是JavaScript: var start = $(".datepicker").kendoDatePicker({
有没有可能将剑道 ui 网格的最后一列锁定到最右边?我想让用户始终看到行操作按钮,将它锁定在左侧感觉有点奇怪 最佳答案 请在您的页面中添加以下代码段。 .k-grid-content-loc
我正在使用 Kendo UI 网格,如下所示: function refreshGrid() { $(".k-pager-refresh.k-l
我想使用 Kendo UI 开发一个网站。我可以使用 kendo-ui 的其他资格.但是,我无法在 ASP.NET 中使用文件上传。是否有任何示例代码或文档可以解决这个问题? 最佳答案 这就是它对我有
dataSource.changed 事件是否有效? 实例化我的 Kendo UI 网格后,我将按照此处的文档绑定(bind)更改事件: http://docs.kendoui.com/api/fra
我是 Kendo UI PanelBar 的新手。当用户单击按钮时,我想使用 javacript 扩展面板栏。谢谢你的帮助。 @(Html.Kendo().PanelBar()
我的页面中有一个下拉列表,这是代码: Role: Roles:
我正在使用剑道 slider 。我的要求是,对于每个 slider 值的更改,我都需要更改剑道 slider 的背景颜色。 最佳答案 如果要更改 slider 的背景,可以执行以下操作: $("#sl
你好,我正在使用 asp.net mvc 4 开发一个应用程序,我正在使用 kendo 添加 DataGridView!我有一些麻烦: 我想在 datagridview 的列中添加两个属性 我有一个模
以下代码无效。谁能帮我在这里写 else if 条件? function getMyColumns() { return [{ field: "xxx",
我正在使用 kendo ui 创建一些网格。下面的代码示例是促使我实现的代码示例。我在开发过程中遇到了一个错误,我尝试了一些解决方法,但都没有奏效。 http://dojo.telerik.com/A
我是一名优秀的程序员,十分优秀!