Guest User

Untitled

a guest
Apr 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. app.directive('ngJqGrid', function ($compile) {
  2.  
  3. console.log("Directive called");
  4.  
  5. var link = function (scope, element, attrs) {
  6. scope.$watch("config", function (newValue) {
  7. element.children().empty();
  8. var table = angular.element('<table id="' + newValue.id + '"></table>');
  9.  
  10. element.append($compile(table)(scope));
  11.  
  12. angular.extend(newValue, {
  13. datatype: 'json',
  14. myType: 'GET',
  15. contentType: "application/json; charset-utf-8",
  16. jsonReader: {
  17. root: 'Data',
  18. page: 'Page',
  19. total: 'TotalPages',
  20. records: 'Count',
  21. repeatitems: false,
  22. },
  23. loadComplete: function () {
  24. $compile(angular.element('#' + newValue.id))(scope);
  25. },
  26. autowidth: true,
  27. //altRows: true,
  28. pager: true,
  29. pageinput: true,
  30. rowNum: 10,
  31. rowList: [5, 10, 20, 50, 100],
  32. sortable: true,
  33. viewrecords: true,
  34. emptyrecords: "No records to view",
  35. loadtext: "Loading..."
  36. })
  37.  
  38. angular.element(table).jqGrid(newValue);
  39. });
  40. };
  41.  
  42. return {
  43. restrict: 'E',
  44. scope: {
  45. config: '=',
  46. },
  47. link: link
  48. }
Add Comment
Please, Sign In to add comment