Retrieve grid view row item through radcontext menu.

3 posts, 0 answers
  1. Sandip
    Sandip avatar
    15 posts
    Member since:
    Nov 2010

    Posted 19 Jan 2011 Link to this post

    Hi,

     

    I've a Gridview and bind it through ViewModel. My grid is showing the Data Perfectly and pagination is working.

     

    When I right click on any GridView row the context menu is coming; When I click on "Employee Info" it'll opened a new child window (passing EMPID to child window) that will show the Whole Employee Info.

     

    HOW DO I FETCH EMPID IN THIS SCENARIO?

     

    How do I Pass EMPID parameter through CommandParameter?

     

    <telerik:RadGridView Name="EmpGridView" ItemsSource="{Binding PagedSource,ElementName=radDataPager}"

                                 SelectedItem="{Binding SelectedEMP}" 

                                     IsBusy="{Binding IsLoading}"

                                     SelectionMode="Extended"                           

                                             AutoGenerateColumns="False"

                                             ShowGroupPanel="False">

                    <telerik:RadContextMenu.ContextMenu x:Name="GridContextMenu">

                        <telerik:RadContextMenu>

                            <telerik:RadContextMenu.Items>

                                <telerik:RadMenuItem Header="Employee Info"

                                                     Command="{Binding EmpInfoCommand,Source={StaticResource ViewModel}}"                                                  

                                                     CommandParameter="{Binding SelectedItem.EMPID,ElementName=EmpGridView}"></telerik:RadMenuItem>

                                <telerik:RadMenuItem Header="Delete"

                                                     Command="{Binding DeleteEmpCommand,Source={StaticResource ViewModel}}"                                                 

                                                     CommandParameter="{Binding SelectedItem.EMPID,ElementName=EmpGridView}"></telerik:RadMenuItem>

                            </telerik:RadContextMenu.Items>

                        </telerik:RadContextMenu>

                    </telerik:RadContextMenu.ContextMenu>

                    <telerik:RadGridView.Columns>

                        <telerik:GridViewSelectColumn></telerik:GridViewSelectColumn>

                        <telerik:GridViewDataColumn x:Name="EMPID" IsVisible="False" DataMemberBinding="{Binding EMPID}"/>

                        <telerik:GridViewDataColumn DataMemberBinding="{Binding EmpName}" Header="Name" Width="200"/>

                        <telerik:GridViewDataColumn DataMemberBinding="{Binding EmpEmail}" Header="Email" Width="300"/>

                        <telerik:GridViewDataColumn DataMemberBinding="{Binding EmpSal,StringFormat=' {0} k '}" Header="Salary" Width="80"/>

                        <telerik:GridViewDataColumn DataMemberBinding="{Binding EmpJoiningDate,StringFormat=' {0:d} '}"

                                                    DataFormatString="{}{0:d}"

                                                    Header="Date" Width="200"/>

                    </telerik:RadGridView.Columns>

                </telerik:RadGridView>

                <telerik:RadDataPager Name="radDataPager"

                                      Source="{Binding AllEmployee}"

                                      DisplayMode="FirstLastPreviousNext"

                                      PageSize="10"

                                      IsTotalItemCountFixed="True"

                                      AutoEllipsisMode="None"

                                      ></telerik:RadDataPager>

     

    Thank in advance for your valuable input.

  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 21 Jan 2011 Link to this post

    Hi Sandip,

    Your code seems correct and I suppose it is working when you first select the row and then right click it, am I right?
    If so, then you need to automatically select the row that has been right clicked. You can check our online demo on how to do it.

    Best wishes,
    Veselin Vasilev
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. Sandip
    Sandip avatar
    15 posts
    Member since:
    Nov 2010

    Posted 31 Jan 2011 Link to this post

    Thanx for your cooperation; it worked.
Back to Top