【问题标题】:Create full jqGrid directive in AngularJS在 AngularJS 中创建完整的 jqGrid 指令
【发布时间】: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


【解决方案1】:

如果你想合作,我正在做这个! ngGrid

【讨论】:

    猜你喜欢
    • 2017-05-27
    • 1970-01-01
    • 1970-01-01
    • 2013-12-25
    • 1970-01-01
    • 2017-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多