我有以下网格结构
$scope.grid = $("#prospectsGrid").kendoGrid({
columns: [
{ template: "<input type='checkbox' class='checkbox' />", width: "3%" },
{ template: "#= FirstName + ' ' + LastName #", title: "Name" },
{ field: "FirstName", hidden: true },
{
command: [
{
name: "edit",
text: "<span class='glyphicon glyphicon-pencil' aria-hidden='true'></span>"
}
}).data("kendoGrid");
如您所见,我正在使用 #prospectsGrid 标识符访问此网格。现在不改变网格内的任何功能,我需要用一些角度元素替换标识符( #prospectsGrid )。我怎样才能做到这一点?任何帮助,将不胜感激。
仅供参考,我的 HTML代码是
<div id="prospectsGrid" class="gridcommon"></div>
答案 0 :(得分:1)
正如 micjamking 在评论中所说,你需要注入你的模块KendoUI指令。
angular.module("myApp",["kendo.directives"])
然后你可以在你的html代码中使用这样的东西
<div kendo-grid="myKendoGrid"
k-options="myKendoGridOptions">
</div>
在控制器中:
angular.module("managerOMKendo").controller("myController", function ($scope) {
// Functions controller
$scope.createMyGrid = function () {
$scope.myKendoGridOptions = {
columns: [ {
field: "FirstName",
template: "<input type='checkbox' class='checkbox' />", width: "3%"
},
command: [{
name: "edit",
text: "<span class='glyphicon glyphicon-pencil' aria-hidden='true'></span>"
}]
// Here you can put your complete configuration. Check official example
}
}
}
// Main thread
$scope.createMyGrid(); // call the function that creates the grid
});
这是official example
你可能需要改变一些东西。例如,我写了文本,也许你必须写模板。没有掠夺者很难。