Two implementations of Jqgrid sorting:

Source: Internet
Author: User
Tags jqgrid

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.