ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on November 07, 2017, 02:49:07 pm
-
I use data stored as JSON (array of objects) which is loaded through script src. I would like to refresh data (reload src) and update grid with new data ...what would be the best approach for this?
-
Call refreshDataAndView() method to refresh data in grid.
Please also read this topic: https://paramquery.com/pro/tutorial#topic-loaddata
-
Trying:
$.getScript(url)
.done(function() {
$( "grid" ).pqGrid( "option", "dataModel.data", data);
$( "grid" ).pqGrid( "refreshDataAndView" );
});
data is fetched but there seem to be no update...?
-
data is undefined in your code.
-
url is js src which contains
var data = [{col1:'value1' etc...}]
I get no erros when running, but data is not updated.
-
Are using the same variable data to send data to remote server and assigning the same data to grid? This is incorrect.
Please check the documentation of getscript for correct usage: https://api.jquery.com/jquery.getscript/
-
No, I just want to update grid with new data by loading the .js again, Like this:
var data = [{*updated data*...}]
$( "grid" ).pqGrid( "option", "dataModel.data", data);
$( "grid" ).pqGrid( "refreshDataAndView" );
Or how should I do this?
Thanks.
-
yes the data should be updated data, which is not the case in your previously posted code.
You are not receiving any date from done callback.
In your code it's
.done(function()
It should be
.done(function( data )
-
Thanks, however still confused, why does this not work?
{
type: 'button',
label: "test",
listener: function() {
var data=[{col1:'value1'}]
$( "grid" ).pqGrid( "option", "dataModel.data", data);
$( "grid" ).pqGrid( "refreshDataAndView" );
}}
-
$( "grid" ) doesn't look right.
Please check the selector of your grid or better use "this" variable inside listener as reference to grid.
https://paramquery.com/pro/tutorial#topic-methods
-
Thanks, solved.