Altering and hiding fields without updating the complete fields configuration
See original GitHub issueI am transitioning from Datatables (http://datatables.net) to js-grid because Datatables is bloated and dusty and js-grid made a very good first impression on me.
However, I am missing convenient ways of altering or hiding fields that I temporarily don’t want to show. Updating the complete ‘fields’ option via $('#my_grid').jsGrid('option', 'fields', []);
seems too cumbersome, because in addition to the changed field, I also always need to include the static fields that I never intend to change in the configuration array.
A utility method like jsGrid.alterField(column_name, new_settings)
or jsGrid.alterField(column_name, key, value)
would be really helpful for reducing overhead.
Hiding a column via CSS is not ideal either, because that messes up the widths of the other columns that have been calculated by js-grid. Datatables has a “visible” property for each field. This way, you can preconfigure all columns, even the ones that you don’t want to show immediately. When the time has come, you can simply change the “visible” property to true and the preconfigured column will show up. In combination with the abovementioned alterField()
method you could easily show and hide columns with the benefit of js-grid recalculating the widths of the other columns, so that everything looks nice all the time.
A call to $('#my_grid').jsGrid('alterField', 'my_hidden_column', 'visible', true);
would make my hidden column show up and re-render the table, so that all widths are recalculated nicely.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
So, in fact this feature is doesn’t work. We were unable to use it. It actually not hide, but destroy element from DOM. If we use it, we can’t get access to data of hidden field.
@tabalinas the field value should be hidden but preserved and be able to be sent over to the server using insertItem function.