0

Is it possible to add columns at run-time? Suppose I have a paginated set of data that has 4 columns on page 1 and the same 4 columns PLUS 1 more different columns on page 2, then on page three have the same 4 columns as page 1 but 2 columns different than page 2.

i.e.
Page 1 columns in data and shown in grid:

File, DocName, PrintDate, Event

Page 2 columns in data and shown in grid:

File, DocName, PrintDate, Event, Person

Page 3 columns in data:

File, DocName, PrintDate, Event, RunDate, Designation

Page 3 columns shown in grid:

File, DocName, PrintDate, Event, Person, RunDate, Designation

And they will all remain in the grid when maneuvering back and forth between the pages.

MB34
  • 4,210
  • 12
  • 59
  • 110

1 Answers1

1

You can do this by adding all columns that are to be shown in the grid to all pages initially.

Then, when the grid is loaded, hide the columns that should not be visible for the first page, by using this function: http://www.shieldui.com/documentation/grid/javascript/api/methods/hideColumn

Then attach a "change" event handle for the grid pager:

$("#grid").swidget().pager.on("change", function(e) {
    var currentPage = this.currentPage;

    // hide the cols not supposed to be visible on this page 
    // and show the rest - using the grid's hideColumn() and 
    // showColumn() functions
    // ...
});
Vladimir Georgiev
  • 1,949
  • 23
  • 26
  • The columns to be shown for all pages will NOT be known until records are fetched. There could be over 15,000 records and it takes 1-2 min to retrieve that data from server via the web service. – MB34 Oct 26 '15 at 15:49
  • You can do the initialization after the data is fetched - there is the "dataBound" event for capturing that. – Vladimir Georgiev Oct 26 '15 at 16:01