This is a migrated thread and some comments may be shown as answers.

How To get Selected Row Index In Telerik Rad Grid?

5 Answers 3008 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arjun
Top achievements
Rank 1
Arjun asked on 18 Jan 2014, 07:55 AM
Hi All,

Am Using Telerik Grid In my Windows 8 Metro App.

Howw Do I get the Selected Row Index in Grid?

I Mean When i Click on perticular Row I want to get all the values in that row.


Thanks
Arjun

5 Answers, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 21 Jan 2014, 08:57 AM

Hello Arjun,

Thank you for the question.

There are two ways to get the selected item of the RadDataGrid:

  • You can use the SelectionChanged event of the RadDataGrid:

    void RadDataGrid_SelectionChanged(object sender, DataGridSelectionChangedEventArgs e)
    {
        var selectedItem = e.AddedItems.FirstOrDefault() as DataItemClass;
    }
  • The RadDataGrid has a SelectedItem property:

    var selectedItem = grid.SelectedItem as DataItemClass;

    This is a dependency property, that you can also bind to a property from your view model.

I hope this was useful. Please, let us know if you have further questions.

Regards,
Rositsa Topchiyska
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Arjun
Top achievements
Rank 1
answered on 21 Jan 2014, 09:51 AM
Hi,
Thanks For The Reply.

My Question Is I Want Row Index Directly.. Not The Items In That ROW..
0
Rosy Topchiyska
Telerik team
answered on 23 Jan 2014, 07:39 PM

Hi Arjun,

You can use the RadDataGrid.GetDataView() method to get the list of all data items that are currently contained in the View and get the index of the selected item like this:

private void RadDataGrid_SelectionChanged(object sender, DataGridSelectionChangedEventArgs e)
{
    var selectedItem = e.AddedItems.FirstOrDefault() as Data;
    if (selectedItem != null)
    {
        var index = (sender as RadDataGrid).GetDataView().Items.ToList().IndexOf(selectedItem);
    }
}

I hope this helps. Please, let us know if we can assist you in some other way.

Regards,
Rositsa Topchiyska
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Arjun
Top achievements
Rank 1
answered on 15 Oct 2014, 11:05 AM
Hi,

How to Get Selected Items From The RAD GRID ?
0
Tsvyatko
Telerik team
answered on 17 Oct 2014, 08:04 AM
Hello Arjun,

You can check this help article - http://www.telerik.com/help/windows-8-xaml/raddatagrid-selection.html

Regards,
Tsvyatko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid for XAML
Asked by
Arjun
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Arjun
Top achievements
Rank 1
Arjun
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or