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
340
Get all checked Items in Grid
posted

hi,

I have this simple grid with a filter and checkboxes.

The user can check items and press OK to get extra info for the checked items.

I get the checked items like this: $(element).igGrid("selectedRows").

The problem I have now is when there is a filter active. He returns all the checked rows, but when I try and get the value of a row that is filtered out, it crashes.

this is the way i get the value: $(grid).igGrid("getCellValue", row.index, columnName)

Is there a way to get those values?

  • 5513
    Verified Answer
    Offline posted

    Hello Sebastian,

    When the row is filtered out its element doesn't exist and row.index is set to -1. However, for each of these filtered out rows you still have their primary keys in the selectedRows collection returned by the API function. This means you can use the PK to find the record in the data source and obtain the value you need from the record directly.

    In your case it will probably look like this:

     $(grid).igGrid("findRecordByKey", row.id)[columnName]

    If you don't have a primary key defined for the grid, Selection generates them automatically and assigns them to the records' ig_pk properties. There is no built-in way for searching by this auto-generated primary key, however, you can still manually traverse the data source yourself. Provided 'row' is an object returned by selectedRows, getting the value you need will look like this:

    var dataSource = $(grid).data("igGrid").dataSource.data();

    for (i = 0; i < dataSource.length; i++) {

        if (dataSource[i].ig_pk === row.id) {

            value = dataSource[i][columnName];

            break;
        }
    }

    I hope this helps! Please, let me know if you have any other questions or concerns!

    Thank you for using Infragistics forums!

    Best regards,

    Stamen Stoychev