Nobody can rely on "id" field not existing in some random data pulled from SQL server, for example. To learn more, see our tips on writing great answers. I wanted to do it in MVVM way, hence I designed my solution as follows: In viewmodel I populate MyDataTable and have the following: I am able to get the row index of selected cell. privacy statement. Then get started with AG Grid Enterprise. The index is based on the sorted but unfiltered row list. @oliviertassinari @dtassone Do you agree to go with the refactor? Share Improve this answer Follow edited May 12 at 13:35 answered May 12 at 13:30 T3sTR int row = Grid.GetRow(YourDataGridsName); var listOfCells = datagrid.SelectedCells.ToList(); var columnNumber = listOfCells[0].Column.DisplayIndex; Were sorry. Note: DataGrid stores each row ID in string internally so if the ID from your original row data is number you may want to convert it toString () before comparing. So user understands the position based on his sorting criteria. using System;using System.Collections.ObjectModel;using System.Reflection;using System.Windows;using System.Windows.Controls;using System.Windows.Media; namespace DataGridCurrentRowIndex{ public partial class MainWindow : Window { ObservableCollection people = new ObservableCollection { new Person{Name = "Tom", Age = 10}, new Person{Name = "Ken", Age = 20}, new Person{Name = "Jen", Age = 30}, }; public MainWindow() { InitializeComponent(); DataContext = people; } private void Button_Click(object sender, RoutedEventArgs e) { if (datagrid.SelectedCells.Count > 0) { DataGridCell cell = DataGridHelper.GetCell(datagrid.SelectedCells[0]); this.Title = DataGridHelper.GetRowIndex(cell).ToString(); } } } public class Person { public string Name { set; get; } public int Age { set; get; } } public static class DataGridHelper { public static DataGridCell GetCell(DataGridCellInfo dataGridCellInfo) { if (!dataGridCellInfo.IsValid) { return null; }. This has advantages such as: Setting Row IDs is done using the getRowId() grid callback: When the row data contains a unique row identifier, such as a Database Primary Key, getRowId() can be implemented as follows: The example below has getRowId() implemented to return params.data.id. Is there a higher analog of "category with all same side inverses is a groupoid"? How did muzzle-loaded rifled artillery solve the problems of the hand-held rifle? The changes can solve this issue(#1119), but will cause other problems, such as: I don't really see a resolution in both mentioned PRs. So far, I do not see any performance issues with this approach. How long does it take to fill up the tank? I am facing the similar problem. As my datagrid selection unit is "Cell", datagrid1.selectedindex always returns me -1. http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/winfx/2006/xaml. Could you post a simplerepro (markup/code) if youre having the problem? @m4theushw @dtassone I'm not sure why it's closed? On example below, select a cell, and press escape key to invoke button to show the row index of a selected cell on window title. relative to all rows. It's MIT licensed and Open Source. disableMultipleSelection is only available in DataGridPro, not DataGrid. We can then install and use Create React App using npm to create our project, by running the command below: npm i create-react-app. What's new in AG Grid 28.1.0Minor release with new features and bug fixes. for identifying what The next step is to create a new React project from the terminal by running the command below: npx create-react-app data-grid cd data-grid npm start. Sign in I am able to get selected column index from datagrid1.SelectedCells[0].Column.DisplayIndex, but I am not sure how to get selected cell's row inde. Company No. What's new in AG Grid 28.2.0Minor release with new features and bug fixes.