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
Check/uncheck rows conditionally in Hierarchal child grid
posted

Hi Team,

I am using Ignite v9.1.28, Hierarchal grid load on demand feature.

Requirement: I want to select/unselect rows based on condition. Also want to retrieve the list of selected rows.

I am using Igx-checkbox, but unable to retrieve the list of selected rows.

Also i want to select ALL checkbox in the header.

HTML:

<igx-column field="" header="" [resizable]="true" sortable="false" width="70px">
                <ng-template igxCell let-cell="cell" let-val>
                    <span><igx-checkbox  [checked]="true" (change)="toggle($event, cell.row.rowData.childId)">
                 </igx-checkbox></span>                                                    
          </ng-template>
  </igx-column>

Please help me to achieve the same.
  • 2700
    Offline posted

    Hi Shobhana,

    A grid with rowSelection mode set to ‘multiple’ has a default “Select All” checkbox in the row selectors header cell. This checkbox selects/deselects all records of the corresponding grid (not row island). Please, check out these checkboxes and the multiple row selection functionality in this demo from our documentation.

    The snippet you have attached shows an attempt to retemplate a regular cell, not a header, though. A header template has to be created as follows:

    <igx-column field="Name">
        <ng-template igxHeader let-column>
        </ng-template>
    </igx-column>

    More information about header templates in the grids can be found here. Still, I can suggest leveraging the default “Select All” checkbox functionality, as it is already built-into the grid and its behavior is fully tested.

    Regarding retrieving the selected rows, this can be done for each grid, or on the row island level. For your convenience, I created this sample, where the array of selected IDs for the parent grid is displayed. They can be accessed via the selectedRows property of the grid. The sample also demonstrates retrieving an array of the selected IDs for all the grids in the “Orders” row island. It leverages some of the exposed grid API to retrieve them, and once again – the selectedRows property:

     this.rowsSelectedInOrdersRI = [];
        const grids = this.hGrid.gridAPI.getChildGridsForRowIsland('Orders');
        for (let chGrid of grids) {
          this.rowsSelectedInOrdersRI = this.rowsSelectedInOrdersRI.concat(
            (chGrid as GridType).selectedRows
          );
        }

    In conclusion, please, check out the referenced resources and let me know if they help. Additionally, you will have to refer to the version 9 API in the referenced API links, to check what is available in this version. 

    Best regards,
    Bozhidara Pachilova
    Associate Software Developer