Search code examples
javascriptjqueryasp.net-mvc-4slickgriddynamic-columns

Slickgrid id column


Is there a way to bypass the necessity for an ID column? My goal is to display 100,000+ results dynamically. Currently, the only way I have found to do this is to create an "id" column on the table and then loop through it (which is quite costly). If this is the case, is there a more efficient way of doing this? How can I hide the column when the grid is displayed?


Solution

  • Since the usage of a dataview is causing the unique id requirement, then using a simple array as your data would suffice in removing the restriction.

    If the advanced functionality of a dataview is required then you have the option of providing a field/property within the setItems call that will provide/override the id field (the field must be present within each data object and have uniqueness across all the data elements). If you cannot guarantee those two conditions, only two options are left.

    • customize the source code of the dataview to provide a UUID during the processing of updateIdxById
    • manually iterate the data and inject a UUID (what you are currently doing)

    Regarding the column displaying:

    Only those fields for which you have provided a column definition are rendered within the grid. Thus, as long as you don't provide the field in a column definition it will not be rendered. You can see in this example that each data object contains an id property but none of the elements of the columns array has a field that points to that property, as such it does not appear as a column.