Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Single state for RowIslands + RowIsland onColumnInit not triggering?
posted

Hi,

I was looking into state persistence for hierarchical grid and it seems like there is not out-of-the-box support for feature that I'm trying to implement so I'm looking for help here.

I'm trying to implement such grid where user can save state for both parent and child grids (rowIsladns), but, child grids should ALL have the same layout, column widths and so on... So like a single state for all row islands.

With current implementation of state persistence, each row island has it's own state and it's tied to parentRowId which means if I load some other data, the state/s are of no use for this scenario, and also, since every rowIsland has it's own state, there is no "single" state so I would need to choose one of those to be the "master" state (which is not a major issue).

But, when reading state for hierarchical grid, "RowIsland" state/s are not included unless they are toggled open. Which means, if I save state for hierarchical grid while RowIslands are closed, I'm going to lose state of those.

1st Q: is there a way to implement such state persistence where, when I click some button "SAVE", I'm saving parent grid layout (which already works) and also, for example, always take the 1st RowIsland state and save it as "child grid state" and apply that state to all child grids when I reload page? So like a child grid state that is not tied to specific row island and not tied to specific rowParentId, kinda like saving a parent grid state?

My current solution idea - I could maybe show a hint to user that it is required to have at least one RowIsland open when saving state in order to also read child grid state, and if more rowIslands are open, it will take the first one's state.
And if no RowIslands are open, or grid is empty, it will ignore it and keep the previously saved/default state.

This leads to second question.

2nd Q - It seems like "OnColumnInit" does not trigger for RowIsland component? So I'm not able to restore columns templates for row islands. How is that supposed to work? Or does it work only for parent grids?

Thank you.

  • 1560
    Verified Answer
    Offline posted

    Hello,

    I have been looking into your questions and regarding the first one what I could say is that by design calling the getState method would return a string or IGridState object containing all features applied to the parent grid with calculated states of all row-islands where some feature is applied.

    Once you get this value you could modify it depending on your requirement before setting it to the grid on restore. So, you could access the rowIslands collection and modify it by adding all other child grids and setting their state to be the same as the first one. However, please note, that overriding the default behavior could cause unexpected behavior in some scenarios and should be handled entirely on application level which is beyond the scope of Infragistics support.

    I have prepared a small sample that demonstrates a possible approach and it could be found here. However, one limitation of this approach is that the row selection feature cannot be restored. Also, please keep in mind that this sample is not fully tested and it is just an example of a possible approach, so depending on your data structure and scenario, there could be some other side effects. Having this in mind, I believe that the best suggestion is to use the default grid's behavior.

    Regarding the second question I could say that after testing it on my side I have logged this behavior in our GitHub repository here. In order to receive a notification whenever new information is available please make sure that you are subscribed to the issue. This can be achieved via the “Subscribe” button.
    Meanwhile, I could suggest using the rowIslands' gridCreated event where you could access the column collection and loop through the columns:

      public rowIslandGridCreated(ev) {
        requestAnimationFrame(() => {
          const columns = ev.grid.columns;
        });
      }

    Please let me know if you need any further assistance regarding this matter.


    Sincerely,
    Teodosia Hristodorova
    Software Developer