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
665
Accessing hidden row primary key column value via selected cell
posted

I have an igGrid with two columns, the 1st being a hidden column (key = "Name") which contains the row primary key, and the second just a simple string value.  I have implemented custom delete row functionality via a javascript function which accesses the selected cell's row index as follows:

var cell = $("#gridTerms").igGridSelection("selectedCell");
var rowIndex = cell.rowIndex;

This works as expected.  I then need to extract the rowId (primary key) value of the row to be deleted, but since it is a hidden column, I can only access it via the underlying datasource as follows:

var ds = $("#gridTerms").igGrid("option", "dataSource");

then trying the following:

var rowId = ds.Records[rowIndex].Name; //the primary key column = "Name"

This doesn't work, as the row index I got from cell.rowIndex is relative to the current page being displayed, not the row index relative to it's position in the datasource, so it actually returns the incorrect rowId, so doing:

$("#gridTerms").igGridUpdating("deleteRow", rowId);

will delete the wrong row.

How do I get the correct rowIndex for the selected cell/row in the underlying datasource when paging is enabled?

Parents
No Data
Reply
  • 665
    posted

    I now determine the row index value for the selected cell/row in the underlying datasource as follows:

    var pageIndex = $("#gridTerms").igGridPaging("pageIndex");

    var pageSize = $("#gridTerms").igGridPaging("pageSize");

    var dsRowIndex = rowIndex + (pageIndex * pageSize);

    but trying to access the primary key rowid value in the datasource row as follows doesn't work:

    var rowId = ds.Records[dsRowIndex].Name;

    I have also tried 

    var rowId = ds[dsRowIndex].Name;

    but that doesn't work either.

Children