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

Double clicking a grid row displays the Edit screen

8 Answers 198 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Harshal
Top achievements
Rank 1
Harshal asked on 13 Apr 2011, 08:30 AM
Hello
I am using Rad WPF grid.
I have a requirement of opening up a new screen(edit screen) on double clicking on grid row. I also have a checkbox column and Edit button on my screen. Another requirement is when I tick checkbox grid column and click on Edit button should open a new screen(edit screen).
Please guide. Also kindly let me know whether these two functioalities can be achieved at a time

8 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 13 Apr 2011, 08:38 AM
Hi Harshal,

If you want to open a new window on double clicking on the row, you may handle the RowActivated event of the grid. Furthermore, you may take a look at this forum thread for additional reference.
As for the second requirement, my suggestion would be to expose a new boolean property in your business object and set it in the DataMemberBinding of that column. Thus when pressing the "Edit" button, you may verify whether this property is true and open the edit window. 
 

Best wishes,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Harshal
Top achievements
Rank 1
answered on 13 Apr 2011, 09:16 AM
Can you please provide code sample or a link where RowActivated event is used?
0
Maya
Telerik team
answered on 13 Apr 2011, 09:41 AM
Hi Harshal,

You may subscribe to the event as follows:

XAML:
<telerik:RadGridView Name="playersGrid"
                             RowActivated="playersGrid_RowActivated"
                             ItemsSource="{Binding Players}"
                             AutoGenerateColumns="False">
C#:
private void playersGrid_RowActivated(object sender, Telerik.Windows.Controls.GridView.RowEventArgs e)
        {
 
        }

The event will be fired on double-clicking on the row or on pressing Enter. Do you experience any troubles with handling it ? 


All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Harshal
Top achievements
Rank 1
answered on 13 Apr 2011, 10:50 AM
Actually we are using MVVM pattern in our application. So if this event is added then it will be a part of xaml.cs file which we do not want. we want it to be handled in ViewModel class.
0
Harshal
Top achievements
Rank 1
answered on 13 Apr 2011, 10:54 AM
WE are also using EventToCommand approach of MvvmLightSample. Kindly let me know if we can use something like CommandBindings for RowActivated. Kindly provide sample code.
0
Maya
Telerik team
answered on 14 Apr 2011, 07:59 AM
Hello Harshal,

Firstly, please take another look at the forum thread suggested above - it demonstrates how you may use an attached behavior so that you do not need to write any code in code-behind. You may use the sample attached at the last reply in the thread.
Furthermore, you may try the following:

<swi:EventTrigger EventName="RowActivated">
                    <swi:InvokeCommandAction Command="{Binding MyCommand, Source={StaticResource MyViewModel}}"
                                             CommandParameter="{Binding ElementName=clubsGrid}" />
                </swi:EventTrigger>
            </swi:Interaction.Triggers>

Another possibility might be to do like:
<i:Interaction.Triggers>
                                    <i:EventTriggerEventName="RowActivated">
                                        <cmd:EventToCommandCommand="{Binding Path=MyCommand, Source={StaticResource MyViewModel}" PassEventArgsToCommand="True"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>

 

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Harshal
Top achievements
Rank 1
answered on 14 Apr 2011, 11:20 AM
Thanks a lot. This has resoved my problem.
0
Harshal
Top achievements
Rank 1
answered on 14 Apr 2011, 04:15 PM
Can you please provide ViewModel class C# code for the same?
Tags
GridView
Asked by
Harshal
Top achievements
Rank 1
Answers by
Maya
Telerik team
Harshal
Top achievements
Rank 1
Share this question
or