Skip to content

Replies

0
Charles Cymbor
Charles Cymbor answered on Apr 23, 2021 11:44 PM

This works for getting all the filtered row:

for (let i = 0i < grid.actualDataSource.actualCounti++) {
        const item = grid.actualDataSource.getItemAtIndex(i);
}
0
Charles Cymbor
Charles Cymbor answered on Apr 22, 2021 6:56 PM

Hi Michael, 

I thought this was working but it actually only works for what is visible on the screen. I need to get all the rows that are currently in the table after filtering.

0
Charles Cymbor
Charles Cymbor answered on Apr 21, 2021 9:28 PM

Hi Aleksandar,

I was able to implement this through the use of template columns. This solution rely’s on storing the selected state on the row information itself (isOrderSelected in my code). Here is what my code looks like

  const handleSelectAllCheckbox = (selectAllState: boolean) => {
    if (ordersGrid?.current) {
      for (
        let i = ordersGrid.current.actualDataSource.firstVisibleIndexRequested;
        i <= ordersGrid.current.actualDataSource.lastVisibleIndexRequested; i++ ) { const item = ordersGrid.current.actualDataSource.getItemAtIndex(i); ordersGrid.current.selectedItems.remove(item); if (selectAllState) { ordersGrid.current.selectedItems.add(item); } } } }; const orderCheckBoxHeaderCellUpdating = (header: IgrTemplateHeader, args: IgrTemplateHeaderCellUpdatingEventArgs) => {
    const content = args.content as HTMLDivElement;
    let checkBox: HTMLInputElement;

    let selectedFound = false;
    let nonSelectedFound = false;

    if (ordersGrid?.current) {
      for (
        let i = ordersGrid.current.actualDataSource.firstVisibleIndexRequested;
        i <= ordersGrid.current.actualDataSource.lastVisibleIndexRequested; i++ ) { const item = ordersGrid.current.actualDataSource.getItemAtIndex(i); if (!!item?.isOrderSelected) { selectedFound = true; } else { nonSelectedFound = true; } if (selectedFound && nonSelectedFound) { break; } } } if (content.childElementCount === 0) { checkBox = document.createElement("input"); checkBox.type = "checkbox"; checkBox.onchange = (ev: Event) => {
        handleSelectAllCheckbox((ev.target as HTMLInputElement).checked);
      };
      content.appendChild(checkBox);
    } else {
      checkBox = content.children[0] as HTMLInputElement;
    }

    checkBox.checked = selectedFound && !nonSelectedFound;
    checkBox.indeterminate = selectedFound && nonSelectedFound;
  };

  const orderCheckboxCellUpdating = (column: IgrTemplateColumn, args: IgrTemplateCellUpdatingEventArgs) => {
    const content = args.content as HTMLDivElement;
    const isOrderSelected = args.cellInfo.rowItem.isOrderSelected;
    let checkBox: HTMLInputElement;
    if (content.childElementCount === 0) {
      checkBox = document.createElement("input");
      checkBox.type = "checkbox";
      content.appendChild(checkBox);
    } else {
      checkBox = content.children[0] as HTMLInputElement;
    }

    checkBox.checked = isOrderSelected;
  };

  const [orderColumns, setOrderColumns] = useState<JSX.Element[]>([]);
  const createOrderColumns = useCallback((orderColumnSettings: ColumnCollection) => {
    const orderColumns: JSX.Element[] = [];

    const header = new IgrTemplateHeader({});
    header.cellUpdating = orderCheckBoxHeaderCellUpdating;

    orderColumns.push(
      
    );
    
    //more columns here
    }

Here is what it looks like when rendered:

0
Charles Cymbor
Charles Cymbor answered on Apr 9, 2021 7:21 PM

I found the rows in the debugger in gridRef.actualDataSource.c2.a4._inner 

Is there a public API to get to those rows?