Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// within widget _create()
  2. tihs.dataTable = this.$dataTable.dataTable({
  3.     order: [[1, "asc"]],
  4.     columns: [
  5.         {
  6.             data: null,
  7.             orderable: false,
  8.             defaultContent: "",
  9.             createdCell: this._createExpandCell.bind(this)
  10.         },
  11.         // ...
  12.         // data columns
  13.         // ...
  14.         {
  15.             data: null,
  16.             orderable: false,
  17.             defaultContent: "",
  18.             createdCell: this._createControlCell.bind(this)
  19.         }
  20.     ],
  21.     serverSide: true,
  22.     deferLoading: 0,
  23.     ajax: function (data, callback, settings) {
  24.         DemoDataService.GetData("Snapshots", callback, data);
  25.     }.bind(this)
  26. });
  27.  
  28. /// widget methods
  29. _createExpandCell: function (cell, cellData, rowData, rowIndex, colIndex) {
  30.     $(cell)
  31.         .append($("<span></span>")
  32.             .ExpandButton({
  33.                  isExpanded: false,
  34.                  expanded: function() {
  35.                     let dataTableRow = this.dataTable.api().row(rowIndex);
  36.                     if (dataTableRow.child() == null) {
  37.                         dataTableRow.child("<div></div>").show();
  38.                         dataTableRow.child().children().html("FACTS TABLE PENDING");
  39.                     }
  40.                     else {
  41.                         dataTableRow.child.show();
  42.                     }
  43.                 }.bind(this),
  44.                 collapsed: function () {
  45.                     this.dataTable.api().row(rowIndex).child.hide();
  46.                 }.bind(this)
  47.             }));
  48. },
  49. _createControlCell: function (cell, cellData, rowData, rowIndex, colIndex) {
  50.     $(cell)
  51.         .append($("<span></span>")
  52.             .button({
  53.                 text: false,
  54.                 icons: {
  55.                     primary: "ui-icon-pencil"
  56.                 }
  57.             })
  58.             .click(function () {
  59.                 Dialogs.EditSnapshot.Open(rowData, function (event, result) {
  60.                     if ((result.result === "save") || (result.result === "retake"))
  61.                         this.dataTable.api().row(rowIndex).data(result.snapshot);
  62.                 }.bind(this));
  63.             }.bind(this)));
  64. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement