How to add array new key value ( javascript ) ?
sample image http://i.hizliresim.com/dj3OLn.png
example this my array
source.localdata[0].c_Id="2d5955ee-415b-470a-8700-3ae65ee122db"
Name ="mike"
LastName="jonas"
source.localdata[1].c_C_ID"b851c285-035f-4a51-8237-1e3c3528e089"
Name ="richard"
LastName="gere"
and I want to enter key and value data
source.localdata[0].Address = "mike for address"
source.localdata[1].Address = "richard for address"
..more
output
source.localdata[0].c_Id="2d5955ee-415b-470a-8700-3ae65ee122db"
Name ="mike"
LastName="jonas"
Address = "mike for address"
source.localdata[1].c_C_ID"b851c285-035f-4a51-8237-1e3c3528e089"
Name ="richard"
LastName="gere"
Address = "richard for address"
I wrote this code but I am getting error JavaScript runtime error: Object doesn't support property or method 'push'
function dataSourceCompare(newdata) {
for (var i = 0; i < source.localdata.length; i++) {
for (var j = 0; j < newdata.dynamicColumns.length; j++) {
if (crewItems[i].c_C_ID === newdata.dynamicColumns[j].ColumnValue) {
source.localdata[i].push([newdata.dynamicColumns[j].ColumnName, newdata.dynamicColumns[j].ColumnValue]);
}
}
}
}
thank you
localdata[0].c_Address = "Address for Mike"(judging from his screenshot the other keys are also prefixed by"c_").c_Addressto an existing localdata entry. But the answer already showed you how to do it, using yourdynamicColumns:).