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

Index of visible selected row

3 Answers 41 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marc Weintraub
Top achievements
Rank 1
Marc Weintraub asked on 28 Feb 2012, 09:54 PM
I'm working with a gridview that has a CellTemplate with a CheckBox column and I'm able to set the IsEnabled value using the following code.

    IList<CheckBox> cbks = myGridView.ChildrenOfType<CheckBox>().ToList<CheckBox>();
    MyObject selectedProject = myGridView.SelectedItem as MyObject;
    int SelectedIndex = myGridView.Items.IndexOf(selectedProject);
    cbks[SelectedIndex].IsEnabled = True;
 

This works great, but except ChildrenOfType<>() only provides the rows for visible rows. I can not set EnableRowVirtualization to False.



How do I get the index of the visible row that is within the List of checkboxes (chks)?


Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 29 Feb 2012, 07:54 AM
Hi Marc,

My recommendation would be to count on bindings instead. What you can try is to bind IsEnabled property of the CheckBox through a converter (IValueConverter) and set it to true/ false depending on your custom logic.
Will that approach fit into your requirements ?  

All the best,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Marc Weintraub
Top achievements
Rank 1
answered on 29 Feb 2012, 03:54 PM
Thanks for the reply.

Unfortunatly, as it sits, I'm unable to bind it to a property. There are other factors, then a simple value, that enables/disables that checkbox.

Can you provide an example of using the IValueConverter for use with custom logic?

Marc.
0
Maya
Telerik team
answered on 01 Mar 2012, 09:14 AM
Hi Marc,

Could you provide a bit more details about your exact scenario ? When do you want to enable/ disable a specific CheckBox ? What will that depend on ? 

Regards,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Marc Weintraub
Top achievements
Rank 1
Answers by
Maya
Telerik team
Marc Weintraub
Top achievements
Rank 1
Share this question
or