ParamQuery grid support forum
General Category => Help for ParamQuery Grid (free version) => Topic started by: kavyasetty on November 25, 2013, 04:42:22 pm
-
i am using JSON data to pass the data to paramquery grid and it is displayed on grid perfectly. but my question is that if there are any changes in the data via grid.. how can it be captured and how to pass the data form pqgrid to controller as it has to be saved to database on click of a button .
-
Use JSON.stringify method to convert JSON data of grid into string and send it to server using $.ajax.
var data = JSON.stringify(dataModel.data);
$.ajax({url: url, data: data});
-
thanks for the reply.
i tried the above. it dint work to get the data from pqgrid.
the scenario is as follows.
i have a button called save . so when i click the button the pqgrid data must be captured and stored in var data.
-
Do you get error?
Could you please post your source code of the grid including the source code in the button.
-
thanks for the reply.
the code that you have posted worked for me. I had made mistake with the syntax.
i have another question ,
var dataCell = $( "#fragment-1" ).pqGrid( "getEditCellData" );
alert('data in cell '+dataCell.toString())
here i am able to get the content of the cell. But how is it possible to get the row and column index of this cell??
-
use
http://paramquery.com/api#method-getEditCell
and
http://paramquery.com/api#method-getCellIndices
-
I am using the below code to get the data from the grid and pass it to the controller,
var data = JSON.stringify(dataModel.data);
$.ajax({url: url, data: data});
i am able to capture the data from the grid ,but when i am passing the data via the url and trying to retrieve it in my servlet i am only able to get the data of 1st row of the grid. but i have data in 10 rows
-
I get the row by the row index and build by json based on my model. This works for me so far.
var row = ui.rowIndx;
jsonstring = { "ID": ui.data[row].ID, "FiscalYear": ui.data[row].FiscalYear };
Update(JSON.stringify(jsonstring));//send whole row in json to Update function
-
var data = JSON.stringify(dataModel.data); in this i am getting error as dataModel not defined....
i have used the sample code
$('#button1).click(function(){
var data = JSON.stringify(dataModel.data);
$.ajax({url: url, data: data});
});
as my idea is that when i press this button than i get a JSON which i can send....
-
dataModel has a special meaning, it's name of the option in pqGrid.
http://paramquery.com/api#option-dataModel
-
yes sir but i am unable to get how can i use dataModel.data in jsonstringfy() function.....as standalone....because i can only used it as
$( ".selector" ).pqGrid( "option", "dataModel", { data: dataSales } );
and now if i do something like this.....var t1=dataModel.data;
Than i get error...can you please let me know the correct way..
-
you can get reference of dataModel
var dataModel = $grid.pqGrid( "option" , "dataModel");
var data = dataModel.data;
or dataModel.data directly
var data = $grid.pqGrid( "option" , "dataModel.data");
-
Thanks a lot...sir :)
-
Hi,
is it possible to sort the dataModel befor doing:
var data = JSON.stringify(dataModel.data);
i want to sort it by sortIndx: "Name".