Skip to content

SMALL improvements in the usage of jqGrid

Oleg Kiriljuk edited this page Mar 2, 2015 · 3 revisions

Introduction

There are many standard problems and typical errors of newcomers in the usage of jqGrid. One of the goal of free jqGrid 4.8 was to simplify the usage of jqGrid and to reduce restrictions and to probability of the errors. It will be tried to find a compromises between the possibly good compatibility with the previous versions of jqGrid and still simplifying of the usage.

The changes in free jqGrid 4.8

One don't require to include grid.locale-en.js

One don't need to include grid.locale-en.js if one need to use en-US locale. All required settings are included already in jquery.jqGrid.min.js (jquery.jqGrid.src.js).

Assigning of id of the base grid <table> is optional

jqGrid required to have unique id attribute assigned to the base <table> element of the grid. If the <table> have no such id then jqGrid assign it automatically.

One don't need to create <div id="pager"></div>

It's allowed to use pager: true option. It create automatically the empty <div> an generate unique id to it. After creating of jqGrid the value of pager option will be modified from true to the id selector of the pager div. So one can use getGridParam to get the value if it's required. The behavior of pager: true option is very close to behavior of toppager: true option which is long supported in jqGrid to create top pager. It is possible to us both pager: true and toppager: true to create two pagers: one on the top of the grid and another one on the bottom of the grid.

The default values of some options are changed

  • height: "auto" are used now instead of height: 150 used before. It improves the visibility of small grids or the grids having small number of rows. No scrollOffset: 0 are required to remove unneeded free space which one sees on some grids which have no vertical scrollbar. If one want to hold the old 150 value one need to include height: 150 option explicitly.
  • gridview: true are used as default with the only exception: afterInsertRow callback are defined. The usage of gridview: true improves performance of rendering of the grid. In case of usage afterInsertRow in old projects instead of much more effective cellattr, rowattr or custom formatters one will have backward compatibility.
  • editurl: "clientArray" are use now instead of editurl: null used before. It allows to use local editing without minimal additional efforts and the requirement to have any server part implemented.
  • cellsubmit: "clientArray" are use now instead of cellsubmit: "remote" used before if cellurl is undefined.

Dynamic default values of some options

  • dynamic default value is used now for the datatype option. If one uses input option data or if one don't specified any url option, then undefined datatype will be initialized to "local". If one uses no data option and specifies url option then one initializes datatype to "json" if the input option jsonReader are used. In case of usage any other combinations of input parameters the option datatype will be set to "xml" to stay the mostly compatible to jqGrid 4.7.0 and older.
  • dynamic default value is used now for rowNum option. The default value rowNum: 20 will be changed to 10000 (the value of the new maxRowNum property) if no pager exists in jqGrid (no pager and toppager: true option are used) or if one uses jqGrid option, which switches off the pagination (like treeGrid: true). New jqGrid option maxRowNum can be used to change the maximal value of rows displayed in the grid from default value 10000 to another value. By the way jqGrid allow now to specify rowNum: 0 or rowNum: 0. In the case jqGrid replaces the rowNum value to maxRowNum during initialization of the grid.

Allow to create TreeGrid with datatype: "local"

jqGrid 4.7 and earlier don't support the usage of datatype: "local", but it's known the trick which allows to do almost the same using datatype: "jsonstring". jqGrid uses the same trick and changes the input options datatype: "local" and input data option to datatype: "jsonstring" and datastr option. It simplify the usage of local TreeGrid.