get iTotalDisplayRecords in another method/odd popup
get iTotalDisplayRecords in another method/odd popup
So because of how our code is set up we arent using the normal PHP file to handle all the data returns. Instead we make our calls via ajax and get a parsed JSON reply containing our information which is displayed correctly on the table. I have manipulated our controller class to insert the itotalrecords value into the string so the pagination can accurately display our count, HOWEVER i cant figure out how to manually tell it the number to display or filter (iTotalDispalyRecords). So as it is right now it will say for example displaying 1-10 of 22 records but show all 22....In addition the search/filter does not work, i see it making new GET pulls everytime i type something in but it does not update the table. Now if i take bServerSide and set it FALSE, then everything works except after i execute a delete, i get my popup confirming that its been done however the table will not refresh, i must manually hit the reload and then it displays the updated table. If also change from using fnDraw to fnReloadAjax, i get a stream of popups simply saying 'false' and after OKing through about 20 of those then it reloads.....im stuck on what to do to fix either one of these routes
heres the code:
Controller for the Json string
datatablecontroller.java
[code]
@RequestMapping(value = "/dataTable/getCmsGroupData", method = RequestMethod.GET)
@ResponseBody
public String getDataTableCmsGroupData() throws JsonParseException, IOException{
System.out.println("in dataTableCmsGroup/getData...");
List cmsGroupList= cmsGroupDao.getDMR();
int listsize = cmsGroupList.size();
String processedResult =parseJSON(cmsGroupList);
String jasonString ="{ \"iTotalRecords\": "+listsize+"," + "\"iTotalDisplayRecords\": "+listsize+"," +
" \"aaData\": " +
processedResult +"}"
;
System.out.println(jasonString);
return jasonString;
}
[/code] As you can see i have fed it the total size int listsize twice as i cant figure out how to call and pass in a value to iTotalDisplayrecords.
and our displayer code cmsgroup.jsp:
[code]
$(document).ready(function(){
var oTable = $('#dataTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"sDom": 'pT<>rt',
"sAjaxSource": 'dataTable/getCmsGroupData',
"aoColumns": [
{ "mData": "id", "sTitle": "ID",
"fnRender": function (oObj) {
return '' + oObj.aData["id"] + '';
}},
{ "mData": "version", "sTitle":"Version" },
{ "mData": "name", "sTitle": "Name" },
{ "mData": "description", "sTitle": "Description"},
{ "mData": "notes", "sTitle": "Notes"},
],
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [{
"sExtends": "ajax",
"bSelectedOnly": "true",
"sButtonText": "Delete Selected",
"mColumns": [0],
"bHeader": false,
"sAjaxUrl": "dataTable/delete/cmsGroup",
"fnAjaxComplete": function ( XMLHttpRequest, textStatus ) {
alert('Delete processed');
oTable.fnDraw(false);
}//delete button
},//aButtons
"select_all",
"select_none",
{
"sExtends": "text",
"sButtonText": "Create New Entry",
"fnClick": function ( nButton, oConfig, oFlash ) {
window.location = "cmsgroup_add";
}
}//add button
]//
}//tabletools
});//.rdy
} );
CMS Group
[/code]
Anyone have any ideas? Thanks!
heres the code:
Controller for the Json string
datatablecontroller.java
[code]
@RequestMapping(value = "/dataTable/getCmsGroupData", method = RequestMethod.GET)
@ResponseBody
public String getDataTableCmsGroupData() throws JsonParseException, IOException{
System.out.println("in dataTableCmsGroup/getData...");
List cmsGroupList= cmsGroupDao.getDMR();
int listsize = cmsGroupList.size();
String processedResult =parseJSON(cmsGroupList);
String jasonString ="{ \"iTotalRecords\": "+listsize+"," + "\"iTotalDisplayRecords\": "+listsize+"," +
" \"aaData\": " +
processedResult +"}"
;
System.out.println(jasonString);
return jasonString;
}
[/code] As you can see i have fed it the total size int listsize twice as i cant figure out how to call and pass in a value to iTotalDisplayrecords.
and our displayer code cmsgroup.jsp:
[code]
$(document).ready(function(){
var oTable = $('#dataTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"sDom": 'pT<>rt',
"sAjaxSource": 'dataTable/getCmsGroupData',
"aoColumns": [
{ "mData": "id", "sTitle": "ID",
"fnRender": function (oObj) {
return '' + oObj.aData["id"] + '';
}},
{ "mData": "version", "sTitle":"Version" },
{ "mData": "name", "sTitle": "Name" },
{ "mData": "description", "sTitle": "Description"},
{ "mData": "notes", "sTitle": "Notes"},
],
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [{
"sExtends": "ajax",
"bSelectedOnly": "true",
"sButtonText": "Delete Selected",
"mColumns": [0],
"bHeader": false,
"sAjaxUrl": "dataTable/delete/cmsGroup",
"fnAjaxComplete": function ( XMLHttpRequest, textStatus ) {
alert('Delete processed');
oTable.fnDraw(false);
}//delete button
},//aButtons
"select_all",
"select_none",
{
"sExtends": "text",
"sButtonText": "Create New Entry",
"fnClick": function ( nButton, oConfig, oFlash ) {
window.location = "cmsgroup_add";
}
}//add button
]//
}//tabletools
});//.rdy
} );
CMS Group
[/code]
Anyone have any ideas? Thanks!
This discussion has been closed.