Skip to content

selectedRow returns null

New Discussion
Yren Criado
Yren Criado asked on Jul 1, 2016 8:17 AM

Hi! I’ve been researching a lot to find my problem but didn’t find the solution. I hope you can help me.

This is my js code:

$(document).ready(function () {

$("#mainTable").igGrid({
 autoGenerateColumns: false,
 dataSource: dataTable, //introduce the JSON array with data
 autoCommit: false,
 columns: [ //the keyword in igGrid for defining the columns
  { headerText: "System Table", key: "SysTableName", dataType: "string" },
  { headerText: "Created by", key: "CreatorUser", dataType: "string" },
  { headerText: "Table Name", key: "TableName", dataType: "string" },
  { headerText: "Number of Columns", key: "ColumnsNumber",
   dataType: "number", width: '10%' },
  { headerText: "Column Type", key: "ColumnType", dataType: "string" },
  { headerText: "Length", key: "Length", dataType: "number" },
  { headerText: "Nulls", key: "AreNulls", dataType: "string", width: '5%' },
  { headerText: "Updates", key: "Updates", dataType: "string", width: '5%' },
  { headerText: "Remarks", key: "Remarks", dataType: "string" },
  { headerText: "Scale", key: "Scale", dataType: "number" }
],
features: [
 { name: "Filtering" },
 { name: "GroupBy", columnSettings: [
  { columnKey: "TableName", allowGrouping: false }]},
  { name: "Sorting", type: "local" },
  { name: "Paging", type: "local", position: "top", pageSize: 20 },
  { name: "Selection", persist: false, mode: 'row', multipleSelection: false,
   rowSelectionChanging: handler, mouseDragSelect: false, touchDragSelect: false }
 ],
 width: '100%'
});

function handler(event, args) {
 //THIS RETURNS NULL (row == NULL)
 var row = $("#mainTable").igGridSelection("selectedRow");
 if (!row) {alert("row is null");} //just a test

 //THIS WORKS JUST FINE, but needs non-fixed row index
 //var cellContent = $("#mainTable").igGrid("getCellValue", 10, "TableName");
} //end handler() });

 

My intention is to get the content of a certain cell

once I select the row.

That method, commented in my code, works just fine,

but I can’t get the “selectedRow” method

to work, so I can use the index property in row.

I wonder what I’m not doing right, but I can’t seem to find it.

Thank you for your help.

Regards.

Sign In to post a reply

Replies

  • 0
    [Infragistics]Tsanna
    [Infragistics]Tsanna answered on Jun 30, 2016 3:04 PM

    Hello Yren,

    rowSelectionChanging event is too early to access the selected row. Please note that this event fires before row is about to be selected. Instead I suggest you to use rowSelectionChanged event. About how to get the row index property, rowSelectionChanged event is more appropriate because it provides the index of the currently selected row through: ui.row.index. Please let me know if you have further questions.

    Regards,
    Tsanna

    • 0
      Yren Criado
      Yren Criado answered on Jul 1, 2016 8:17 AM

      Dear Tsanna,

      Thank you for your help! That worked awesomely.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Yren Criado
Favorites
0
Replies
2
Created On
Jul 01, 2016
Last Post
9 years, 8 months ago

Suggested Discussions

Created by

Created on

Jul 1, 2016 8:17 AM

Last activity on

Feb 25, 2026 9:45 AM