I am adding record in grid using startEditingNew
method as below.
var COLUMN_NAME = {
name : "user_name",
lastname : "user_surname",
age : "user_age"
};
addDataToGrid : function (name, lastname, age){
MyGrid_Grid.startEditingNew({
COLUMN_NAME.name: name,
COLUMN_NAME.lastname: lastname,
COLUMN_NAME.age: age
});
}
But, my above function raise error and does not add record to grid. If I use "user_name" string instead of "COLUMN_NAME.name" , It works fine.
How can I use variable as column name??
Thanks in advance
This is a javascript question, not a SmartClient one.
Anyway, if you need to use that approach, you may write something like:
addDataToGrid : function (name, lastname, age){
var record = {};
record[COLUMN_NAME.name] = name;
record[COLUMN_NAME.lastname] = lastname;
record[COLUMN_NAME.age] = age;
MyGrid_Grid.startEditingNew(record);
}