Author Topic: refreshDataAndView, refresh all except one.  (Read 3117 times)

roetnig

  • Newbie
  • *
  • Posts: 1
    • View Profile
refreshDataAndView, refresh all except one.
« on: August 29, 2016, 03:51:05 pm »
Hi!

I'm using pqgrid for a small personal project. The data is loaded remotely via JSON. The filtering is done locally.

I have several buttons (#btn_xxxx) that perform a change to the State field in the database. I show in the grid all records that have certain value in State field. Everytime I change a value I perform refreshDataAndView

Code: [Select]
$('#grid').pqGrid('refreshDataAndView');
The table reloads the data and wverything is fine, except WITH THE VERY LAST RECORD.

Say I have five records, I change the state and after the refresh I see four . etc... when I'm on the last record, I change the State and refresh.... and the record remains there. No matter if I click on the bottom bar refresh icon, last record remains the same!

I tested the JSON and it gives me no records at all.

Seems like the refreshDataAndView is not loading the data properly.

Finally if I reload the page, the data is correct, no records to show.

Sure it's something stupid that I'm missing, but it's driving me nuts!  :o

Code: [Select]
var colM = [
{width: 50, title: 'id', dataIndx: 'Id', dataType: 'integer'},
{width: 150, title: 'state', dataIndx: 'state'},
{width: 50, title: 'loglast',  dataIndx: 'loglast'},
{width: 50, title: 'country', dataIndx: 'country',    render:function( ui ){
var rowData = ui.rowData;
if(rowData['ES']!=null){return "<img src='../images/FLAGS/24/" + rowData['Country'] + ".png'>"; }
}
}
];

var dataModel = {
location: 'remote',                       
dataType: 'JSON',
method: 'GET',
contentType :'application/json; charset=UTF-8' ,
getUrl : function () {         
return { url: 'getSRCH.php?w=' + w + '&x:' + Date.now()};
},
getData: function ( response ) {               
return { data: response };               
}
};

$('#grid').pqGrid({
dataModel: dataModel,
colModel: colM, 
scrollModel:{pace: 'fast', autoFit: true, theme: true },
title: 'log entries',
filterModel: { on: true, mode: 'AND', header: true, type: 'local'  },
collapsible: false,
refresh: function( event, ui ) {
$('#btn_Modif, #btn_Anul, #btn_Anota, #btn_Extend, #btn_Cancel').hide();
$('#grid').pqGrid('option', 'title', 'Log entries')
},
  rowSelect: function (evt, ui){
if (ui.rowData) {
$('#btn_Modif, #btn_Anul, #btn_Anota, #btn_Extend, #btn_Cancel').show();
$('#grid').pqGrid('option', 'title', 'Log entries [Selected: ' + ui.rowData['Id'] + ' ]');
}
}
});





paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: refreshDataAndView, refresh all except one.
« Reply #1 on: August 29, 2016, 06:04:53 pm »
I don't see any way to reproduce the issue with posted code. Can you share a jsfiddle.