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
1415
Igx Hierarchical grid expand of child grid shows incorrect data
posted

Hi team,

I am using Infragistics version 9.1.28 and will update in upcoming month but this is requirement i have to deliver.

Issue: Using Hierarchical Grid load on demand feature. We are expanding first child row by default, the first child row has no data.

When i expand the second child row, it call the api and data is displayed. But the issue is when i hover on first child expand icon it displays second row child data.

Is there any feature where if i expand the second child row than first child collapses and everytime i click on the expand/collapse icon, the OnGridCreated() event is triggered?

TS: 



Please note as this is an ongoing project so please reply ASAP.

Parents Reply
  • 460
    Verified Answer
    Offline posted in reply to Shobhana Suara

    Hello,

    Thank you for the additional information and clarification.

    I have been looking into your question and regarding the new requirements you have for only one row with row island child data to expand at one time, what I could suggest you as an approach is to handle the onRowToggle event of hierarchical grids again.

    <igx-hierarchical-grid
        #hierarchicalGrid
        [data]="localdata"
        [primaryKey]="'ID'"
        (rowToggle)="rowToggle($event)"
      ></igx-hierarchical-grid>

    When expanding a given row, you will check if we actually have a collapse or expand again with the expanded property of the event and, in addition, you will have a created variable that will keep the row id of the row that is being expanded, and in the check you will also check if you have not already taken the row id and is it different from what is being expanded.

    public rowToggle(event){
        if(event.expanded && this.rowExpandID !== event.rowID){
        }
    }

    If you have a row expand and its id is different from what is stored in the variable then you will cancel the event itself with the cancel property of the event.  After you cancel the event, you will get this redid of the row that is currently being expanded.

    event.cancel = true;
    this.rowExpandID = event.rowID;

    After that, in the setTimeout function, with a given short period of time, you will collapse all rows that are currently expanded with the collapseAll method, or that is, you will collapse the previous expanded row. Finally, again in another setTimeout function with a slightly longer time than the first one, you will expand this row for which the toggle event was fired, as with the expandRow method, and you will pass the variable in which its rowID is kept.

    setTimeout(() => {
                    this.hGrid.collapseAll();
    }, 50);
    
    setTimeout(() => {
                    this.hGrid.expandRow(this.rowExpandID)
    }, 200);

    To summarize, if you have a row expansion and it is a new row that is not expanded, you first cancel the event and take its id, then collapse the previous row and finally expand the one for which the event was fired, in this way you will fulfill the requirement that only one row be expanded at one time.

    Regarding your next question about calling your custom onGridCreated() function when the row expand icon is clicked what I could again suggest and I think will accomplish your requirements is to handle the ng-template element with the igxRowCollapsedIndicator directive and in it put the igx-icon element with keyboard_arrow_right text for the row expand icon. On this icon you can handle the click event and execute your given function or create a new function that performs the same logic as your onGridCreated() function or simply call it in the body of the click function.

    <ng-template igxRowCollapsedIndicator let-row>
          <igx-icon (click)="clickFunction(row)">keyboard_arrow_right</igx-icon>
        </ng-template>

    public clickFunction(row){
             this.OnGridCreated()
    }

    The described scenario could be observed here:

    In addition, I have prepared small sample illustrating this behavior which could be found here. Please test it on your side and let me know how it behaves.

    If you require any further assistance on the matter, please let me know.

    Regards,

    Georgi Anastasov

    Entry Level Software Developer

    Infragistics

Children
No Data