Flexigrid with Notes

Source: Internet
Author: User

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

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.