Kendo the grid page parameter problem in the UI (1)

Source: Internet
Author: User

The grid in the Kendo UI is one of the longest-used controls, and when using the paging effect, we pass the paging parameter with our own defined parameters such as:

1 varDataSource =NewKendo.data.DataSource ({2 Transport: {3 read: {4URL: "Corresponding background path", 5ContentType: "Application/json",6Type: "POST", 7DataType: "JSON"8                 },9Parametermap:function(options, operation) {Ten                     if(Operation = = "read") { One                         varparameter = { A Page:options.page, - PageSize:options.pageSize, - Take:options.take, the Skip:options.skip -                         }; -                         returnkendo.stringify (parameter); -                     } +                 } -             }, +Serverpaging:true, APagesize:20, at Schema: { - Model: { -ID: "", -                 }, -Datafunction(response) { -                     returnResponse.data; in                 }, -Totalfunction(response) { to                     returnresponse.total; +                 } -             }, the});

The corresponding grid notation is:

$ ("#XXXX"). Kendogrid ({datasource:datasource, Height:, toolbar:kendo.template ($ ("#template"). HTML ()), pageable: {refresh:true, pagesizes:true, Buttoncount:5, page:1, PageSize:20, pagesizes: [20, 50, 100, 500]}, Columns: [{field:"XX", Title: "XX"}, {field:"XX", Title: "XX"}, {field:"XX", Title: "XX"}, {field:"XX", Title: "XX"}, {field:"XX", Title: "XX"},], selectable:"Row", sortable:true, resizable:true}). Data ("Kendogrid");

Background parsing method (Java backend) When:

@Override Publicstring XXX (string info) {Jsonobject json=Jsonobject.fromobject (info); PageBounds PageBounds=NewPageBounds (Integer.parseint (Json.get ("page"). ToString ()), Integer.parseint (Json.get ("PageSize"). toString ())); Map<String,Object> map =NewHashmap<string, object>();        //Note here defines an empty map that is not assigned, is for placeholder, and can be assigned if needed PageList<map<string, object>> list = (pagelist<map<string, object>>) xxxdao.xxx (PAGEBOUNDS,MAP); Try{List= (pagelist<map<string, object>>) xxxdao.xxx (PAGEBOUNDS,MAP); } Catch(Exception e) {logger.error ("Failed to get information list!" The specific information is: "+e); } jsonobject jsonobj=NewJsonobject (); Jsonobj.accumulate ("Data", Jsonarray.fromobject (list)); Jsonobj.accumulate ("Total", List.getpaginator (). Gettotalcount ()); returnjsonobj.tostring (); }

DAO Layer Impl Code
@Override public List<Map<String,Object>> XXX (pagebounds pagebounds,map<string,object> map) { return sqlsessiontemplate.selectlist ("xxdao.xxx", map,pagebounds); }

In particular, it is important to note that the SelectList () is passed three parameters, the first one is known to be the path of the DAO layer, the second is the other parameters within the page (such as you need to upload from the foreground to the background of the user ID, etc.), the third is your resolution of the foreground grid paging parameters, If you do not need to pass other parameters to the page, the second parameter needs a variable placeholder , which can be null, a number, or an empty variable. If you do not wear parameters, you will get an error. cannot be resolved.

Kendo the grid page parameter problem in the UI (1)

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.