user1268130
user1268130

Reputation: 923

Can we add jqgrid options dynamically?

I have a doubt in Jqgrid. Can anyone tell me,is It possible to add options like 'shrinkToFit:false' or someother options dynamically in Jqgrid.

Can anyone tell how it can be done?

Thanks in advance

Upvotes: 3

Views: 6061

Answers (1)

tpeczek
tpeczek

Reputation: 24125

If you look at jqGrid documentation, you will see that there is a column (last one) which is named Can be changed?. This column tells you if the option value can be set\changed after jqGrid initialization. This column in most cases takes one of following values:

  • No - the option value can't be set\changed after intialization
  • No. Method avail. - there is a special method dedicated for changing this option, the jqGrid methods documentation can be found here.
  • Yes - the option value can be set\changed with setGridParam method like this:

    $('#gridId').jqGrid('setGridParam', { autoencode: true });

  • Yes. Requires reload - the option value can be set\changed with setGridParam method but jqGrid needs to be reloaded in order to use new value. This can be achieved like this:

    $('#gridId').jqGrid('setGridParam', { altRows: true }).trigger('reloadGrid');

I hope this explains the subject in general.

If it comes to shrinkToFit options its value can't be set\changed after intialization - you would need to destroy the grid and built it again.

Upvotes: 7

Related Questions