Server Side values not getting set in DataTable..Help Please
Server Side values not getting set in DataTable..Help Please
XebMax
Posts: 2Questions: 0Answers: 0
At (Server Side) Java level: Here is what I am doing
[code]
responseJSONObject.put("sEcho", 3);
responseJSONObject.put("iTotalRecords",jsonArray.length());
responseJSONObject.put("aaSorting",sortingArray);
responseJSONObject.put("iTotalDisplayRecords", "25");
responseJSONObject.put("aaData", jsonArray);
resourceResponse.setContentType("application/json");
resourceResponse.getWriter().print(responseJSONObject.toString());
resourceResponse.getWriter().flush();
[/code]
Javascript level:
****************
[code]
jQuery('#MyDataTable').dataTable({
"bJQueryUI": true,
"bServerSide": true,
"bProcessing": true,
"sDom": '<"H"<"datatables-header-length"l><"datatables-header-pagination"p>r>t<"F"p>',
"sPaginationType": "full_numbers",
"bStateSave": true,
"sAjaxSource": "<%= viewPortletResourceURL.toString() %>",
"fnServerData": function (sSource, data, fnCallback) {
jQuery.ajax({ "dataType": 'json',
"type": "POST",
"url": sSource,
"data": data,
"success": [fnCallback, someFn],
"error": someFn
});
},
});
[/code]
So my issue I pretty sure values getting set as following Description got updated with what values I set
This gets updated: [quote]"Showing 1 to 25 of 25 entries (filtered from 50 total entries)"[/quote]
But the drop down from which user select number of pages to be displayed not getting updated also datatable is still displaying all 50 records whereas it should display 25 records. I am damn sure I am missing something here
here is JSON OBject that I am passing :(
[code]
{"aaSorting":[2,"asc"],"iTotalRecords":"50","iTotalDisplayRecords":"25","sEcho":3,
"aaData":.....}
[/code]
aaData part is working just fine but none of the others are getting replicated :( please HELP ;(
I am kind of really tough deadline.....really I am beating my head off but cant find the solution, followed exactly what all the internet examples was saying but still not able to fix that...I think I am missing some property/attribute
[code]
responseJSONObject.put("sEcho", 3);
responseJSONObject.put("iTotalRecords",jsonArray.length());
responseJSONObject.put("aaSorting",sortingArray);
responseJSONObject.put("iTotalDisplayRecords", "25");
responseJSONObject.put("aaData", jsonArray);
resourceResponse.setContentType("application/json");
resourceResponse.getWriter().print(responseJSONObject.toString());
resourceResponse.getWriter().flush();
[/code]
Javascript level:
****************
[code]
jQuery('#MyDataTable').dataTable({
"bJQueryUI": true,
"bServerSide": true,
"bProcessing": true,
"sDom": '<"H"<"datatables-header-length"l><"datatables-header-pagination"p>r>t<"F"p>',
"sPaginationType": "full_numbers",
"bStateSave": true,
"sAjaxSource": "<%= viewPortletResourceURL.toString() %>",
"fnServerData": function (sSource, data, fnCallback) {
jQuery.ajax({ "dataType": 'json',
"type": "POST",
"url": sSource,
"data": data,
"success": [fnCallback, someFn],
"error": someFn
});
},
});
[/code]
So my issue I pretty sure values getting set as following Description got updated with what values I set
This gets updated: [quote]"Showing 1 to 25 of 25 entries (filtered from 50 total entries)"[/quote]
But the drop down from which user select number of pages to be displayed not getting updated also datatable is still displaying all 50 records whereas it should display 25 records. I am damn sure I am missing something here
here is JSON OBject that I am passing :(
[code]
{"aaSorting":[2,"asc"],"iTotalRecords":"50","iTotalDisplayRecords":"25","sEcho":3,
"aaData":.....}
[/code]
aaData part is working just fine but none of the others are getting replicated :( please HELP ;(
I am kind of really tough deadline.....really I am beating my head off but cant find the solution, followed exactly what all the internet examples was saying but still not able to fix that...I think I am missing some property/attribute
This discussion has been closed.
Replies
> But the drop down from which user select number of pages to be displayed not getting updated
I don't understand this point - what has the length drop down got to do with the return from the server. It is an input, not an output.
Allan
{"iTotalRecords":50,"iTotalDisplayRecords":25,"sEcho":3,
"aaData":.....}
[/code]
I initially use integer but does not have luck so I learned some where passes a string instead of integer but was not make any difference either way....seems like some thing I am missing some attribute/property while I am writing Javascript :( because table has no effect also I tried passing array thought if it makes any difference but no luck ... clearing it is considering "25" or 25 same data type as if I pass "abc" instead of number.. I could see NaN on the screen which is reasonable..
[quote] But the drop down from which user select number of pages to be displayed not getting updated [/quote]
Sorry i was referring paginate drop down that get enabled disabled using "bLengthChange".. So what i was referring when I am setting value "iTotalDisplayRecords" property to 25, I was expecting ths dropdown should select 25 by default instead of 10...My drop down control has default values means (sizes are 10, 25, 50 and 100)