Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8416855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:53:07+00:00 2026-06-10T01:53:07+00:00

I am trying to do a row selection on my grid but am struggling

  • 0

I am trying to do a row selection on my grid but am struggling on either setting or getting the datakey values as I can not find any documentation out there on it.

$("#divGrid").igGrid({
            columns: [
                { headerText: "@Manage.gridColumnEmployeeNumber", key: "EmployeeNumber" },
            ],
            dataKeyFields: "EmployeeNumber",  //Is this how you set the dataKeys?
            autoGenerateColumns: false,
            dataSource: jsonp,
            features: [
                {
                    name: "Selection",
                    rowSelectionChanging: rowSelectionChanging
                }
            ]
        });
    });

This does not work at all. How do I access my dataKey (primaryKey) in this section of code?

    function rowSelectionChanging(evt, ui) {
        if (confirm) {
            var rows = ui.getSelectedRows();
            var selectedRow = rows.getItem(0);
            var selectedDataKey = selectedRow.get_dataKey();

            alert(selectedDataKey);
        } else {
            return false;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:53:09+00:00Added an answer on June 10, 2026 at 1:53 am

    […]
    dataKeyFields: “EmployeeNumber”, //Is this how you set the dataKeys?
    […]

    Close enough. It’s actually ‘primaryKey’ like so:

    […]
    primaryKey: “EmployeeNumber”,
    […]

    And for the second part I guess that’s not obvious right away, however the row you get passed as an argument is the actual DOM TR element that is being selected and you can (as your current setup suggest) plainly pick the key form its cells like so:

    var rowKey = $(ui.row.element).children().eq(0).text(); //may need to parse if int
    

    Note: The eq() method takes zero based index and in terms of structure the child elements of the row are the cells. In you case the primary key column is the first (and only) and therefore has index 0.

    Another approach I find more programmatic-friendly is to get the key straight from the data source (clearer to read and no need for parsing):

    var rowKey = ui.owner.grid.dataSource.dataView()[ui.row.index].EmployeeNumber;
    

    Note: ‘owner’ is the actual widget in charge of the event ( Selection) and it has a reference to your ‘grid’ and from there you can access the data source. To get the records use either ‘.data()’ or ‘.dataView()’ – the latter contains only the actual visible rows on which the index is based and should be used if any additional features are enabled ( paging, sorting, filtering..).

    Here’s the documentation page that (at the bottom) describes what the selection events provide – http://help.infragistics.com/NetAdvantage/jQuery/2012.1/CLR4.0?page=igGrid_Selection_Overview.html

    And here’s a full API reference: http://help.infragistics.com/jQuery/2012.1/ui.iggridselection#events – from here you can dig into any grid / grid feature / data source API and events have sample snippets with all useful parameters listed.

    P.S. If the intent is not to control the users’ selection, consider using the ‘-ed’ event as in ‘rowSelectionChanged’ – parameters available are identical. The difference is the ‘-ing’ is fired mid-selection and it blocks the UI, which can result in a not very responsive app if you add some more heavy logic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a DataTable with Multiple Row Selection but i'm getting an
I have a query where I'm trying pivot row values into column names and
I am trying to get columns inside row. But I only want to get
I am trying to set the row background color for the advanced data grid
I'm trying to create an application with a UITableView and when selection a row
Hey trying to read stream into image control can any one help also I
I am trying to send custom data to initialize my jqgrid row selection. I
I'm trying to make a table support multiple row selection (for the moment just
im trying to save a row in my settings table, it works all fine
We are trying to bold a row in excel , Visual studio 2008, framework

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.