Introduction:
Jqgrid is a powerful table control that supports sorting, grouping, paging, intra-row editing, table tree, and intra-row tables. the basic platform further encapsulates and extends the platform. make it simpler. easier to use.
Wiki document address
Common property settings
| Attribute name |
Attribute description |
Required? |
Default Value |
| Datasource |
Data Source Address |
Yes |
|
| Pager |
Whether to pagination. If it is set to true, a pagination box is created. |
No |
True |
| Custom_pager |
If it is set to true, a custom page box will be created. Note that if the page value is not set, it will not work. |
No |
False |
| Rownumbers |
Show serial number? |
No |
True |
| Colnames |
Column Title Description, array |
Yes |
|
| Colmodel |
Field Model Description, object, name (bound field), sortable (sorting field), actions (Operation column, array), action_icons (icon column, array) |
Yes |
|
| Autowidth |
Auto Fill width |
No |
True |
| Altrow |
Show banma stripes |
No |
True |
| Jsonreader |
The supplementary description (ID and root element) of the data source has a uniform format. Generally, you only need to configure the ID. |
Yes |
|
| Tbar |
Toolbar description, array, extended attributes (configurable icons, button descriptions and events, add, modify, delete, import, and export buttons have default standard icons |
No |
|
| Rownum |
Number of lines per page |
No |
10 |
| Multiselect |
Select multiple |
No |
True |
| Caption |
Title |
No |
|
| Height |
Height |
No |
Auto |
| Grouping |
Group or not |
No |
False |
| Groupingview |
Specific group configurations (see the example) include groupfield, grouporder, and gridcollapse) |
No |
|
Control event
| Control name |
Event Description |
Required? |
Default Value |
| Onselectrow |
Events that occur when a row is clicked |
|
Null |
| Ondbclickrow |
Events that occur when double-clicking a row (method) |
No |
Null |
FAQs
- How do I obtain the ID of the row selected by the grid?
var rowid = $( "#searchResultList" ).getGridParam( "selrow" );
- How to dynamically Add a row of data in a table?
// $ ("# Jqgrid "). addrowdata (rowid, Data, POs, idx); // POs can be [first, last, before, after], for the latter two, you must specify the relative row ID $ ("# jqgrid "). addrowdata ("1", {"name": "test", "Age": 12}, "first ");
- How to dynamically modify the data content of a row, such as the values of certain columns?
//setRowData( rowid, data ); $( "#jqgrid" ).setRowData( "1" , { tax: "5" , total: "205" });
- Common attributes of jqgrid?
$ ("# Jqgrid "). jqgrid ({URL: "$ {CTX}/sys/role/search. DM ", colnames: [" role name "], //," role code "colmodel: [" rolename "], //" rolecode "can also be replaced with jsonreader: {ID: "roleid", root: "datalist"}, width: 240, height: 250, rownum: 20, // Pager: "loglistpager ", // divid sortname: "actiontime" displayed on the page, // sortorder: "DESC" for the default sorting column name, // default sorting order scroll: True, // scroll over onselectrow: function (rowid ){}});
- Get the data object of a row?
var rowid = $( "#searchResultList" ).getGridParam( "selrow" ); var rowData = $( "#searchResultList" ).getRowData(rowid);
- How can I use APIs to dynamically modify selected rows?
// True: Reload table data; false: Do not reload table data $ ("# jqgrid"). setselection ("1", true );
- How to obtain the value of a column
VaR Col = jquery ("# jqgrid "). jqgrid ('getcol', 4, false); // obtain the value of VaR Col = jquery ("# jqgrid") in column 4th "). jqgrid ('getcol', 'name', false); // obtain the value of a column named name.
- How to delete one or more rows
var selectedId = $("#gridTable").jqGrid("getGridParam", "selrow"); $("#gridTable").jqGrid('delRowData', selectedId);
- Some common APIs
$( "#jqgrid" ).resetSelection(); $( "#jqgrid" ).clearGridData(); $( "#jqgrid" ).setCell(rowid,colname,nData,cssp,attrp);