ParamQuery grid support forum
General Category => Help for ParamQuery Grid (free version) => Topic started by: noctrona on March 03, 2014, 02:19:06 pm
-
Hi,
I met a strange problem.
Please have a look with the following code:
/* part a */
var DM = $("#grid_json").pqGrid("option", "dataModel");
var data = DM.data;
data[rowIndex][colIndex] = 'test';
alert(data[rowIndex][colIndex]);
/* part b */
var DM = $("#grid_json").pqGrid("option", "dataModel");
var data = DM.data;
data[rowIndex]['Name'] = 'test';
alert(data[rowIndex]['Name']);
/* part c */
var DM = $("#grid_json").pqGrid("option", "dataModel");
var data = DM.data;
data[rowIndex][colIndex] = 'test';
alert(data[rowIndex]['Name']);
As the above codes, I have a cell the dataIndex is "Name". If I set value for this cell and get it value by same way, I can get the cell content (like part a&b).
But if I use different way to set and get value. (part c) I can only get an "undefined" value.
Did I have any mistakes for this operation?
Thank you!
-
Please refer to API documentation. data is a javascript array of arrays (for array data) and an array of objects (for JSON data).
data[rowIndx][dataIndx] is the right way to get and set cell data.
colIndx has a special meaning; it means index of column in colModel array.
-
Please refer to API documentation. data is a javascript array of arrays (for array data) and an array of objects (for JSON data).
data[rowIndx][dataIndx] is the right way to get and set cell data.
colIndx has a special meaning; it means index of column in colModel array.
Thanks for your answer. :)