how to use $scope.dtInstance.DataTable.page(page).draw(false) to stay in current page after update
how to use $scope.dtInstance.DataTable.page(page).draw(false) to stay in current page after update
sonali12
Posts: 12Questions: 2Answers: 0
how to use $scope.dtInstance.DataTable.page(page).draw(false) to stay in current page after data table row update.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi sonali12,
If you pass in
page
, instead of false, i.e.then that will keep the ordering and the search as it was. See
draw()
for more info.Cheers,
Colin
Hi sonali12,
The code you have for the
draw()
would also work, bothfalse
and'page'
keeps the paging as it is.When you say "after data table row update", does that also issue a draw?
Thanks,
Colin
yes.again it draws all the data from table.so please give idea where to make this draw false.Coded below but dtinstance showing undefined.
.withOption('stateSaveCallback', function (settings, data) {
For more info:
$scope.dtInstanceCallbackVDR = function (dtInstance) {
I don't actually see the
.draw(false)
in your code chunks above, but that should keep the page in place - here is a trivial example: http://live.datatables.net/migexeve/1/edit .Can you link to a test case showing the issue please?
Allan
These are the options:
(function() {
=========dtInstanceCallback================
$scope.dtInstanceCallbackVDR = function (dtInstance) {
i have added $scope.dtInstance.DataTable.page(page).draw(false);in both .withOption('stateSaveCallback') function and $scope.vdrDtInst = dtInstance.DataTable.on('draw.dt') but its not working any where.
if you want i wil send you the whole page code but please help me out from this issue.
One thing do i need to put below codes as i am calling service again during row update.
[code]
/* in Datatables */
if ( bResetDisplay )
{
oSettings._iDisplayStart = 0;
}
[/code]
and
[code]
/* when updating the table /
bResetDisplay = false; / override default behaviour /
oTable.fnDraw();
bResetDisplay = true; / restore default behaviour */
[/code]
Hang on - you are calling
$scope.dtInstance.DataTable.page(page).draw(false)
inside the state save callback?That's going to end up with an infinite loop since a draw will trigger a state save. I'd suggest removing that line.
Allan
Thanks..yeah i faced that issue and removed that $scope.dtInstance.DataTable.page(page).draw(false) inside the state save callback.But please suggest where to put that code?
Do i have to add something like below?
$.fn.dataTableExt.oApi.fnStandingRedraw = function(oSettings) {
//redraw to account for filtering and sorting
// concept here is that (for client side) there is a row got inserted at the end (for an add)
// or when a record was modified it could be in the middle of the table
// that is probably not supposed to be there - due to filtering / sorting
// so we need to re process filtering and sorting
// BUT - if it is server side - then this should be handled by the server - so skip this step
if(oSettings.oFeatures.bServerSide === false){
var before = oSettings._iDisplayStart;
oSettings.oApi._fnReDraw(oSettings);
//iDisplayStart has been reset to zero - so lets change it back
oSettings._iDisplayStart = before;
oSettings.oApi._fnCalculateEnd(oSettings);
}
};