Issue with inherited code.
Issue with inherited code.
sbirnie
Posts: 11Questions: 1Answers: 0
I've inherited some code and there is an issue where the _START_ value looks like it is stale. Here's the scenario.
1. Page search returns a datatable. At the bottom it displays "Displaying 1 to 200 of 11,000 results"
2. Hit the next at the bottom of the datatable so the custom message displays "Displaying 201 to 400 of 11,000 results"
3. The search parameters are changed and they hit the search button.
4. The datatable is refreshed with the new results, but at the bottom it displays "Displaying 201 to 26 of 26 results".
Does anyone know why the _START_ value is not being set to the correct value? I don't know if showing some code will help or not. If it is please let me know and I'll post anything I can.
Thanks.
1. Page search returns a datatable. At the bottom it displays "Displaying 1 to 200 of 11,000 results"
2. Hit the next at the bottom of the datatable so the custom message displays "Displaying 201 to 400 of 11,000 results"
3. The search parameters are changed and they hit the search button.
4. The datatable is refreshed with the new results, but at the bottom it displays "Displaying 201 to 26 of 26 results".
Does anyone know why the _START_ value is not being set to the correct value? I don't know if showing some code will help or not. If it is please let me know and I'll post anything I can.
Thanks.
This discussion has been closed.
Replies
Nope no idea. Can you give us a link to a test case please?
Allan
[code]
oTable = $("#searchResultsTable").dataTable({
"bDestroy": true
,"sDom": "tpi"
,"bFilter": false
,"bLengthChange": false
,"iDisplayLength": iDisplayLength
,"iDisplayStart": iDisplayStart
,"aaSorting": aaSorting
,"bProcessing": false
,"sScrollY": "200px"
,"bScrollCollapse": true
,"bInfo": true
,"bStateSave": false
,"oLanguage": {
"sInfo" : "Displaying _START_ to _END_ of _TOTAL_ results"
}
,"sPaginationType": "two_button"
,"bServerSide": true
,"sAjaxSource": ""
,"iDeferLoading": iLastQueryCount
,"bDeferRender": true
,"sAjaxDataProp": "mngSearchResults"
,"aoColumnDefs" : [
{"mDataProp":"field1","bSortable":false, "aTargets":[0]}
,{"mDataProp":"field2", "aTargets":[1]}
,{"mDataProp":"field3", "aTargets":[2]}
,{"mDataProp":"field4", "aTargets":[3]}
,{"mDataProp":"field5", "aTargets":[4]}
,{"mDataProp":"field6", "aTargets":[5]}
,{"mDataProp":"field7", "aTargets":[6]}
,{"mDataProp":"field8", "aTargets":[7]}
,{"mDataProp":null, "bSortable":false, "aTargets":[8]}
]
,"fnServerData": function(sSource, aoData, fnCallback) {
// Block the table with a light gray overlay so the user can't do multiple clicks
$('#searchResultsTable_wrapper').block({
message:null,
overlayCSS:{backgroundColor: '#000',opacity:0.2}
});
// Set initial process type to send to the server.
$("#processType").val(processType);
// Clear the selectedRows string since they can't do cross-page edits.
$('#selectedRows').val('');
// Post the form data to the server so it will pick up the search parameters
var formData = $("#SrcForm").serializeArray();
$.each(formData, function(i, field) {
aoData.push({"name":field.name, "value":field.value});
});
// Do the actual ajax post to the server
$.ajax({
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(data, textStatus, jqXHR) {
$('#searchResultsTable_wrapper').unblock();
setButtonsEnabled(true);
// Process any server-side error messages here.
if (!processServerMessages(data) && data.mngSearchResults != null && data.mngSearchResults.length > 0) {
$("#lastQueryCount").val(data.lastQueryCount);
$('#searchResults').show();
isAjaxData = true;
hiddenSearchResultElements = '';
fnCallback(data, textStatus, jqXHR);
$('#hiddenSearchResultElements').html(hiddenSearchResultElements); // Add all the hidden form search results fields back into the DOM Form
$('#searchResultsTable_wrapper .dataTables_scrollBody').scrollTop(0); // scoll up to top on each Prev/Next page
}
},
"error": function(xhr, textStatus, thrownError) {
$('#searchResultsTable_wrapper').unblock();
setButtonsEnabled(true);
handleAjaxError(xhr, textStatus, thrownError);
}
});
}
,"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
// Do any post-processing of server data here before each row is added to the table
if (isAjaxData) {
// doing stuff that would take forever to scrub, so I just deleted
// Create a checkbox to update the selected id list
$('td:eq(0)', nRow).html('');
// Setup the image link to run the associated SC search
var imgSrc = "";
$('td:last', nRow).html('');
//$('td:last', nRow).html('');
}
// Replace any empty cells with a nbsp so IE will show the cell border
$('td:empty', nRow).html(' ');
// Draw the right border since IE doesn't show it when there's no scrollbar
$('td:last', nRow).css("border-right", "1px solid #aaaaaa");
return nRow;
}
,"fnInitComplete": function() {
$('#searchResults').show();
//oTable.fnAdjustColumnSizing(false);
// For some reason, the oTable variable is still null at this point, which conflicts with the DataTables documentation.
// So have to reference the table by getting it from the DOM id.
$('#searchResultsTable').dataTable({"bRetrieve": true}).fnAdjustColumnSizing(false);
if (scrollTop > 0) {
$("#searchResultsTable_wrapper .dataTables_scrollBody").scrollTop(scrollTop);
scrollTop = 0; // prevent this from happening more than once
}
// Make sure processType doesn't remain stuck on 'INIT' mode for each pagination ajax call
processType = 'SEARCH';
// Keep them from doing any type of server-side Ajax pagination or sorting when editing data.
disableDataTablePagination('searchResultsTable');
}
});
[/code]
It is an internally calculated value which is why we'd need a test case to see what is happening. Since you can't provide us with one, you'll likely need to add some debug statements to DataTables core to see what is happening.
Allan