3

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

user1268130
  • 885
  • 3
  • 14
  • 31

1 Answers1

7

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.

tpeczek
  • 23,867
  • 3
  • 74
  • 77
  • Thanks alot. But I have a requirement with jqgrid as I need to add columns using column chooser,so that If I add columns grid size is increasing,sometimes I may get columns like 40.So what I can do now.How to get horizontal scroll if width of jqgrid exceeds. So I tried to use shrinkToFit,but it didnt worked :( – user1268130 Jan 10 '13 at 10:34
  • @user1268130 Well your requirement is pretty far away from the question you have asked. I suggest you ask a new question which describes your scenario in details so comunity can look into it. This question was answered accordingly to its content. Also I suggest you read this question before starting new one: http://stackoverflow.com/questions/8292341/horizontal-scroll-bar-in-jqgrid-when-needed – tpeczek Jan 10 '13 at 10:47
  • Sorry I always forget about this.I got my answer,Now I know how to cal setGridParam :) – user1268130 Jan 10 '13 at 17:11
  • When it says `no method-avail` where do I find the method that is available? – Kellen Stuart Mar 05 '16 at 22:08
  • @KolobCanyon You need to go through the documentation, what is the setting you are looking for? – tpeczek Mar 06 '16 at 06:56
  • @tpeczek I do need to read more carefully through the documentation – Kellen Stuart Mar 07 '16 at 05:36