This content has been marked as final. Show 6 replies
You were on the right track with columns.push(). However, you need to assign the entire columns property for this to work (you can't just add to the existing property). eg:
var columns: Array = new Array();
columns.push(<new column 1>);
columns.push(<new column 2>);
grid.columns = columns; //This will get the grid to use the new columns
Thanks a lot for your answer. It works smoothly. It's a little strange that grid.columns.push doesn't work, since columns is an read/write array.
Yes, the columns property is a weird one. When reading from it, it actually returns a copy of the internal array. Well, if you actually think about it, it does sort of make sense. Because columns is just a regular array, if you did this:
and it actually updated the internal array, you still wouldn't see any change in the grid. A regular array isn't capable of dispatching change events, so the grid has no way of knowing that a new column was added. And then you get a mismatch between what's displayed and what's stored in the component.
Regardless, they really could've implemented the whole thing better to make it more intuitive.