ParamQuery grid support forum

General Category => Help for ParamQuery Grid (free version) => Topic started by: noctrona on March 03, 2014, 02:19:06 pm

Title: Problem when set and get cell content with different way
Post by: noctrona on March 03, 2014, 02:19:06 pm
Hi,

I met a strange problem.
Please have a look with the following code:

Code: [Select]
/* 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!
Title: Re: Problem when set and get cell content with different way
Post by: paramvir on March 03, 2014, 09:21:48 pm
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.
Title: Re: Problem when set and get cell content with different way
Post by: noctrona on March 04, 2014, 08:27:41 am
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. :)