Infragistics, Javascript, Jquery

Infragistics igGrid Get Row Data from Javascript

This isn’t well documented (or at  least I had trouble finding the answer to this), so I figured there may be others (or me again down the road) that could use this information.

Essentially I have a grid loaded from a datasource.  I needed to get at the data of a particular row from outside of any grid event, so I had to retrieve the rows from the grid, find the row that I needed and then reference the data.   All in all, once you know the syntax, it’s not that bad.
This line returns an array of the row data:

var dataRow = $("#igDetails").igGrid("dataSourceObject").Records;

Next we want to retrieve a particular row based on a value in a particular column:

var result = $.grep(dataRow, function (e) { return e.Id === id; });

Result will be an array of rows that match your criteria. In our case I just want the first match (ID will be unique, so should be only one row)

Now to retrieve the data:

var description = result[0].Description;

Pretty simple really, but the retrieving the data from the grid took some looking and piecing parts of the documentation together to get what I needed.

Advertisements