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

Gird RightClick Row MasterTable Get DataKeyNames

2 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cagdas
Top achievements
Rank 1
Cagdas asked on 26 Mar 2014, 02:16 PM
Hi Devoloper Friends;

I'm using a radgird and entry in the properties rowselected feature is activated, 
At the same time, right-click the 'Menu' open. 
I click on the DataKeyNames property value of the row you want to get mss. 
If more than one row is selected, it brings me the value of the first selected row.

Example;

http://elbisemoda.com/Bilgi/RadGridRightClick.png


JavaScript;

function RowContextMenu(sender, eventArgs) {
           var menu = $find("<%=RadMenu1.ClientID %>");
           var evt = eventArgs.get_domEvent();
 
           var index = eventArgs.get_itemIndexHierarchical();
           sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true);

           menu.show(evt);
 
           evt.cancelBubble = true;
           evt.returnValue = false;
 
           if (evt.stopPropagation) {
               evt.stopPropagation();
               evt.preventDefault();
           }
 
 
       }


RadGird;
<telerik:RadGrid ID="grdVeresiyeFisList" AllowFilteringByColumn="false" Height="445px" AutoGenerateColumns="false" runat="server" AllowMultiRowSelection="True" EnableAjaxSkinRendering="True" Culture="tr-TR"
                    GridLines="None" EnableLinqExpressions="False" Skin="Metro" PagerStyle-Visible="false" OnItemCommand="grdVeresiyeFisList_ItemCommand" OnItemDataBound="grdVeresiyeFisList_ItemDataBound"
                    OnNeedDataSource="grdVeresiyeFisList_NeedDataSource" OnDetailTableDataBind="grdVeresiyeFisList_DetailTableDataBind" ShowStatusBar="True" EnableHeaderContextMenu="True" CellPadding="0" CellSpacing="0" ShowFooter="true">
 
                    <HeaderStyle Width="150px" CssClass="cagdasGridHeader"></HeaderStyle>
                    <MasterTableView DataKeyNames="VeresiyeMasterID" NoMasterRecordsText="Kayıt bulunamadı." AllowSorting="True" TableLayout="Auto">
                         
                        <Columns>                          
                            <telerik:GridClientSelectColumn UniqueName="chkSelectColumn" HeaderStyle-Width="30px"></telerik:GridClientSelectColumn>
                            <telerik:GridBoundColumn DataField="VeresiyeMasterID" HeaderText="VeresiyeMasterID" ShowFilterIcon="false" Display="false" UniqueName="VeresiyeMasterID" AllowFiltering="false"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="FisAdi" HeaderText="Fis Adı" UniqueName="FisAdi" HeaderStyle-Width="100px" AllowFiltering="false"></telerik:GridBoundColumn>
                          .......
                          ........
                        </Columns>
                    </MasterTableView>
                    <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" AllowKeyboardNavigation="True"
                        AllowDragToGroup="True" ReorderColumnsOnClient="True" EnableRowHoverStyle="True">
                        <ClientEvents OnRowContextMenu="RowContextMenu" />
                        <Animation AllowColumnReorderAnimation="true" ColumnReorderAnimationDuration="200" />
 
                        <Selecting AllowRowSelect="true"></Selecting>
 
                        <Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
                        <Resizing AllowColumnResize="True" AllowRowResize="false" ClipCellContentOnResize="True"
                            EnableRealTimeResize="True" AllowResizeToFit="True"></Resizing>
                    </ClientSettings>
 
                </telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Cagdas
Top achievements
Rank 1
answered on 31 Mar 2014, 10:22 AM
I'm waiting for help on the subject
0
Viktor Tachev
Telerik team
answered on 31 Mar 2014, 11:30 AM
Hi Cagdas,

In order to access the a DataKeyValue on the client you need to ensure that the appropriate data field is added to the ClientDataKeyNames collection. Check this article that elaborates more on extracting key values client-side.

For your convenience I have prepared a sample project that has a RadContextMenu that is opened on right click on a row in RadGrid. The value from the ID column in the clicked row is also shown. Give this approach a try and let me know if it is working for you. Would you also let me know if I am missing something in your scenario?

I am looking forward to your reply.

Regards,
Viktor Tachev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Grid
Asked by
Cagdas
Top achievements
Rank 1
Answers by
Cagdas
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or