Recently, we need to use the Flexigrid to make a table, to remember some knowledge points.
Two jquery libraries (Jquery.js and Jquery-1.7.1.min.js) were introduced, and there was a conflict, leaving only one
$ ("#gridTable"). Flexigrid ({
URL: './jsp/manager/griddata.jsp ',
DataType: ' JSON ',
......
}
Introduce data with another JSP file, although it's not quite clear why the JSONSTR format is:
for (int i = startrow;i<endrow;i++) {UserInfo user = Userinfolist.get (i); jsonstr+= "{id: '" +user.getid () + "', cell:['" +user.getid () + "', '" +user.getlevel () + "', '" +user.getname () + "', '" + User.getdept () + "', '" +user.getothers () + "']},";} if (jsonstr! = null &&!jsonstr.equals ("")) {jsonstr = Jsonstr.substring (0,jsonstr.length ()-1);} Totalrows = Userinfolist.size (); String jsondata = "{page:" +page_no+ ", Total:" +totalrows+ ", rows:[" +jsonstr+ "]}";/* Output the JSON data to show */out.prin TLN (Jsondata);
At first the stupid thought that just write these two lines of code sortname: "userid", sortorder: "ASC", the table output will be sorted in ascending order according to the account ID.
In fact, it's like this code to fetch data from the database in ascending order of the account ID:
/* Get users ' information from Usertable */
String sql = "SELECT * from Usertable ORDER BY" +sortname+ "" +sortorder+ "Limit" +startrow+ "," +pagesize;
ResultSet rs2 = stmt2.executequery (sql);
But the final sort is to fetch the data from the database, then use the Java List sort collections.sort ()
and the search function, thought that only wrote the
Searchitems: [
{display: ' Account ', Name: ' UserID ', isdefault:true},
{display: ' Permission levels ', Name: ' Level '},
{display: ' name ', Name: ' Username '},
{display: ' Department ', Name: ' Part '}
],
This code can search by criteria, in fact, this is only the style, or to search the results from the database conditionally, the search is finally turned over someone else's blog, found in the griddata.jsp can be used in the two code to pass the value:
Criteria field value?
String query = new String (Request.getparameter ("Query"). GetBytes ("Iso8859-1"), "UTF-8");
Criteria Field
String Qtype = Request.getparameter ("Qtype");
Then determine the output based on the two variables of query and Qtype.
Flexigrid with Notes