Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Copy Grid from one Object to Another? List, Tree or Cube Grid

    Is there a recommend way to copy the data, headers and all styling from one instance of a grid to another?

    So something like:

    Code:
    ListGrid  A = new ListGrid ()   {   overloaded grid methods  specific to this grid type } ;
    A.set (any or most set functions )
    A.setData( records);
    ListGrid  B  = A.copy();
    Or is a step by step B.setDate(A.getData()) of all the parts of A that one wants to copy to B ?

    #2
    The normal way to handle this would be to create a subclass of ListGrid with all the styling etc changes, and then have a couple of instances of that class.

    This is slightly complicated by the fact that you don't want to have two grids pointing to the same actual array instance as its data or its fields (doing this can lead to unpredictable results where as the user interacts with one grid, the other becomes confused about its state).

    The obvious way around this is to create a DataSource which defines the common fields that will be shared by both grids, and will act as a central storage for the data to be displayed in both grids. This can be a client-only dataSource if you want the data defined inline in the application code.
    In addition to this, you can define a default set of actual ListGridField objects for your subclass via listGrid.setDefaultFields()

    If you want to avoid using a dataSource and want to have a standard set of data show up in both grids, you could have a constructor for the class which lazily builds your data object (RecordList or array of ListGridRecords) and applies it via setData() - this would ensure the grids aren't actually pointing to the same underlying data object by reference.

    Comment

    Working...
    X