My dataable (jquery datatables 1.10.5) server-side processing is really true. Everything works from paging here. Here's JSfield I've searched so many posts, everywhere it says "Records total" and "Records filter" should be equal, but it also does not work.
Here is a sample of my code:
$ table.dataTable ({"serverSide": true, "processing": true, "processing": true, "Column": [["data", 1], ["data", 2]], "Ajax": {"Url": "/ test / 0", "dataSrc": function (json) {var data = Json.aaData; return data;}}, "created row": function (row, data, index) {var Chk_name = 'chk_' + data [0] .id; $ ('td: eq (0)', Line) .HTML ('& lt; input name =' '+ chk_name +' "type =" checkbox "value =" 1 "& gt; '); var select_name =' select_ '+ data [0] .id; html = '& Lt; select name = "' + + select_name + '" & gt;' + '& lt; option value = "" & gt; a [& lt; / optio N & gt; '+' & lt; Option & + '& lt; / Options & gt;' + '& lt; / select & gt;' $ ('Td: eq (1)', line). Html (html);},});
Here is a sample of JSR reaction: -
{"draw": 1, "record total" : "11", "record filter": "11", "adata": [[{"id": 1}, {"chk": "at"}, {"operation": ["modify", "delete" "]}]}
Updating with server side code: -
public class DataTableObject {int draw; String record total; String record filter; & Lt; Students & gt; Information; Public int getDraw () drawback; } Public Zero Set Draw (Intro Draw) {this.draw = draw; } Public string getRecordsTotal () {Record records total; } Public Zero set graphs total (string record total) {this.recordsTotal = recordsTotal; } Public string getRecords filtered () {return record filter; } Public Zero setcorder filter (string record filter) {this.recordsFiltered = recordsFiltered; } Public listing & lt; Students & gt; GetData () {Return Data; } Public Zero SatDAdata (list & lt; student & gt; data) {this.data = data; } Public listing & lt; Students & gt; GetAaData () {Return Data; } Public Zero SetAdata (list & lt; student & gt; payee) {this.data = aaData; }}
and the json response is being prepared as follows:
Protected Zero doGet (HTPSArlate Request Request, HTTPSvette Response Response) Servlet Upation, IOxation {Response.setContentType () "application / json"); & Lt; Students & gt; ListOfStudent = getStudentList (); Datatelobject datatable object = new datagram object (); DataTableObject.setDraw ((Integer.valueOf (request.getParameter ("Draw"))); DataTableObject.setRecordsTotal ("2000"); DataTableObject.setRecordsFiltered ("2000"); DataTableObject.setAaData (listOfStudent); Gson gsn = new gsnbuilder () Satty Printing () Create (); String json = gson.tosonson (dataTableObject); Out.print (JSON); } Public List & Student; Students & gt; GetListOfStudents () {List & lt; Students & gt; ListOfStudent = New Arrestist & lt; Students & gt; (); {AStudent = new Student () for (Int i = 1; I & lt; = 200; i ++); String [] name = new string [3]; Name [0] = "Sandeep" + i; Name [1] = "Jaspal" + Mother; Name [2] = "Harpal" + Eye; AStudent.setId ("" + i); AStudent.setChk ("Closed"); AStudent.setOperation (new string [] {"modify", "delete"}); ListOfStudent.add (aStudent); } Return list offstoodants; }
With 1.10, the server start
& amp; For paging length
you need to use them on the list page of your students using the Skip ()
and Low ()
.
For example.
var start = Integer.valueOf (request.getParameter ("Start")); Var length = integer.valof (request.getParameter ("length")); & Lt; Students & gt; ListOfStudent = getStudentList (); & Lt; Students & gt; Filtered list = listoffustant Skip (Start). Move (length) Datatel object. Setadata (filtered list);
It also means that the number of your records (all and filtered) should be counted in those lists:
For example something like this:
Datatable object.trackcodel (listofffent.account); DataTableObject.setRecordsFiltered (filteredList.Count ()); Note: You have not shown any support for search and sort, but they need to be before the page is numbered.
No comments:
Post a Comment