The two ways of realizing the original Lnstjqgrid sort: Implementing a client-side implementation sort: Jqgrid property loadonce:true When all data is loaded on the client, clicking on the column header is automatically sorted by Jqgrid on the client and no longer takes value from the server. Reference file: Ccmxcxtjcc.jsjs settings:
Jqgrid settings: Colmodel: [ { ..... Name: ' Zykj ', Sortable:true, }, ...... }], ...... Loadonce:true,//load all data to the client at a time, sorted by the client. Sortable:true, Sortname: ' zykj ',//Set the default sort column SortOrder: ' ASC ', |
Implementation scenario Two: SQL ordering in the model layer, you need to generate setter, getter method.
Sidx and Sord are variables that jqgrid exist, accepting values that are passed in after the column is clicked. /* * Sord representative collation (ASC, DESC) */ Private String Sord; /** * SIDX represents the column name of the sort */ Private String Sidx; /** * Sord representative collation (ASC, DESC) * @return Sord */ Public String Getsord () { return Sord; }
/* * Set Sord to represent collation (ASC, DESC) * @param Sord */ public void Setsord (String sord) { This.sord = Sord = = null? Null:sord.trim (); }
/** * Get the column names of Sidx for sorting * @return Gets the column name of the Sidx delegate sort */ Public String Getsidx () { return SIDX; }
/** * Set the name of the column that SIDX represents sort * @param sidx */ public void Setsidx (String sidx) { This.sidx = Sidx = = null? Null:sidx.trim (); } |
Jqgrid:
Colmodel: Sortable:true, |
Jqgrid Properties: Sortable:true, Sortname: ' zykj ',//Set the default sort column SortOrder: ' ASC ', |
Loadonce:false,//load all data to the client at a time, sorted by the client. |
Jqgrid Onsortcol is not required to be set in a simple sort. Onsortcol:function (index, Colindex, sortorder) { Jqgridtable.setgridparam ({ SortOrder sorting rules ASC, DESC Colindex Column index 0 start Index: Column name, ' zykj ' }). Trigger ("Reloadgrid"); //}, |
MyBatis configuration file:
The XML settings for select Do not need to be configured statement= "STATEMENT", Sidx, Sord incoming using the $ symbol. Not applicable #. |
<select id= "pageslist" parametertype= "Com.entity.model.ModelDemo" resultmap= "Baseresultmap" > SELECT T1. Sjhs , T1. Zykj From TABLE T1 WHERE 0=0 <if test= "Sidx! = null and sord!=" and sord! = null and SIDX! = ' "" > ORDER by T1.${sidx} ${sord} </if> </select> |
Two implementations of Jqgrid sorting: