I am using slick grid and using a subscribed function to get notification when a cell is edited
grid.onCellChange.subscribe(function (e,args) {
console.log(args);
var a = data[args.row];
// var b = args.grid.getItem(args.row);
var c = args.item;
console.log(a);
// console.log(b);
console.log(c);
console.log("Field Edited:"+ cols[args.cell ].field);
$.post('action_updaterow.php',{'args[]':c},function (data){
alert(data);
})
})
both a and c show as empty arrays in the console, however (as per picture ) when I view args in console item is displayed as an empty array but the items are shown
What does it mean when an array is listed as empty but shows values. The real problem here is that if I pass a
, c
or args.item
into my callback function teh php page doesn't recieve any data.
UPDATE
It turns out I structured my data in the wrong way so it was being returned as an empty Array with properties for the data. This seems to not be understood well by anything - JSON, Jquery, console.log - I fixed the data structure to make each row an object and all is well.
It looks like the Array
is indeed empty. You can give named properties to an Array
just like you can to an Object
. Which means that:
console.log( item.CanPublish ); // "1"
console.log( item.length ); // 0
console.log( item[0] ); // undefined
It is generally advised not to this, as it creates confusion. JavaScript has no such thing as "named arrays". Try to stick to using either an Array
or an Object
.