As discussed with you directly Carlos, I personally don't think it needs to be ArrayList. Usually changing things at this level (swapping 'columns') is rare, but it should be supported. Flex uses Array here too, and I am guessing similar considerations were used in the api design for the Flex DataGrids. Unless we think that those original assumptions have changed or were wrong, then probably it should be ok to keep it the same (as Array).
I did some work on the emulation component support in recent months and iirc this wasn't working, so I made it work similar to Flex, and added a demo/test app for DataGrids in the mxroyale examples for that. One thing that is important is that the columns array be copied in setter and getter. Flex does this also. This means that if you assign the same array twice it will potentially empty and recreate the content. It might be possible to inspect and check the contents of the old array for the same 'DataGridColumn' instances that are included in the new one when the setter is run to optimize some things, but I think it might be something to do as a subsequent optimization if it is 'needed', because the general case of swapping the full set of columns, I think is rare. So i think it is important to use the array.slice() copy in the getter and setter for internal storage of the columns array, otherwise external manipulation of the original array instance can mess things up a lot. I saw this happening in some legacy Flex code until I fixed it in the emulation components. One other thing that was quite common I think is the use of the 'visible' property in DataGridColumn which I don't think we have in Basic or Jewel (but we do in Flex/emulation). This is used more often in Flex for hiding columns, and does not require full refresh of the columns array. On Tue, Jul 21, 2020 at 3:22 AM Carlos Rovira <carlosrov...@apache.org> wrote: > Hi Piotr, > > the main point in Datagrid for columns in "columns", but is an Array (maybe > we could consider to change it to ArrayList?) > > In the current implementation, you need to change all the array, and should > throw away what you have and create a fresh instances of all new columns > and add dataproviders with data to create rows. > > If we had an ArrayList, maybe making an "addItem()" or "addItemAt()" to the > columns collection could handle just the addition of that column > without the need to be so aggressive with the rest of data. > > > > El lun., 20 jul. 2020 a las 12:53, Piotr Zarzycki (< > piotrzarzyck...@gmail.com>) escribió: > > > Hi Guys, > > > > I have requirements to have DataGrid where I'm adding/removing columns > > dynamically. I'm basically going trough the code and trying to figure out > > how everything works and how to approach that problem. > > > > I see that Jewel DataGrid is using class called DataGridButtonBar - It > > seems to me that I should just manipulate that one - basically adding: > > > > header.dataProvider = myNewColumns. > > > > However it does not gives me required result, even more my existing > columns > > are displaying "undefined" in header text. > > > > My general question how would you approach this ? > > > > Thanks, > > -- > > > > Piotr Zarzycki > > > > Patreon: *https://www.patreon.com/piotrzarzycki > > <https://www.patreon.com/piotrzarzycki>* > > > > > -- > Carlos Rovira > http://about.me/carlosrovira >