【发布时间】:2014-09-23 08:41:52
【问题描述】:
我在我的应用程序中使用 jqGrid,但我也想用 jqgrid 原生特性来制作它的 angularjs 指令。
我已将指令设为
var myApp = angular.module('myApp', []);
myApp.directive('ngJqGrid', function () {
return {
restrict: 'E',
scope: {
config: '=',
data: '=',
},
link: function (scope, element, attrs) {
var table;
scope.$watch('config', function (newValue) {
element.children().empty();
table = angular.element('<table></table>');
element.append(table);
$(table).jqGrid(newValue);
});
scope.$watch('data', function (newValue, oldValue) {
var i;
for (i = oldValue.length - 1; i >= 0; i--) {
$(table).jqGrid('delRowData', i);
}
for (i = 0; i < newValue.length; i++) {
$(table).jqGrid('addRowData', i, newValue[i]);
}
});
}
};
});
请参考plnkr链接http://plnkr.co/edit/50dagqDV2hWE2UxG9Zjo?p=preview
但我还需要每行中的编辑和删除按钮及其功能。
请指导我,我怎样才能做到这一点。 :(
【问题讨论】:
-
进一步参考:更好地使用网格的原生 Angular 实现。例如ui-grid.info。没有使用 jQuery
-
@Mazzu 哪里可以实现指令?
-
@MárioMeyrelles,还没有:(
-
公平地说,值得一提的是,“你的代码”实际上是从用户@words-like-jared 那里“借来”的:stackoverflow.com/questions/19433650/angularjs-and-jqgrid
标签: jquery html angularjs jqgrid