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

RadMenu in RadGrid

5 Answers 361 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 15 Sep 2010, 12:07 PM
Hi,

I try to use a Radmenu inside a RadGrid's GridTemplateColumn.
The Result is shown on the attached Picture.
The Menuitems should do a Postback and depending on the selected Menuitem do some Action for the cuttent Row.

Unfortunately I have no idea on how to this.
Can anyone give me a hint, or maybe a better solution to implement this scenario.

Thank you

Thomas

Here is my current code snippet:

<telerik:RadAjaxManager ID="raManager" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="rgOrganisationAnsprechperson">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="rgOrganisationAnsprechperson" LoadingPanelID="ralpLoading" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
  
<telerik:RadAjaxLoadingPanel id="ralpLoading" runat="server" Skin="WebBlue" ></telerik:RadAjaxLoadingPanel>   
<telerik:RadGrid ID="rgOrganisationAnsprechperson" 
    DataSourceID="odsOrganisationAnsprechperson" runat="server" PageSize="20" 
    AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True" ShowGroupPanel="False"
    AutoGenerateColumns="false" GridLines="none" 
    onprerender="rgOrganisationAnsprechperson_PreRender" >
    <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
    <MasterTableView Width="100%">
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldAlias="Organisation" FieldName="Organisationsname" FormatString="{0:D}"
                        ></telerik:GridGroupByField>
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="co_id" SortOrder="Descending"></telerik:GridGroupByField>
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
        <Columns>
            <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="true" EnableShadows="true" ExpandAnimation-Type="None" CollapseAnimation-Type="None" ExpandDelay="0" CollapseDelay="0">
                        <Items>
                            <telerik:RadMenuItem Text="Edit" Selected="false">
                                <GroupSettings ExpandDirection="Right"/>
                                <Items>
                                    <telerik:RadMenuItem Text="Personen Daten">
                                    </telerik:RadMenuItem>
                                    <telerik:RadMenuItem Text="Einstellungen">
                                    </telerik:RadMenuItem>
                                    <telerik:RadMenuItem Text="Zugangsdaten">
                                    </telerik:RadMenuItem>
                                    <telerik:RadMenuItem Text="arbeitet nicht mehr bei Firma">
                                    </telerik:RadMenuItem>
                                </Items>
                            </telerik:RadMenuItem>
                        </Items>
                    </telerik:RadMenu>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" ></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Position" HeaderText="Position" ></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Admin" HeaderText="Admin" ></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Anzeigen" HeaderText="Anzeigen" ></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
      
    <ClientSettings AllowGroupExpandCollapse="True" >
    </ClientSettings>
</telerik:RadGrid>

5 Answers, 1 is accepted

Sort by
0
Accepted
Cori
Top achievements
Rank 2
answered on 15 Sep 2010, 05:29 PM
Hello Thomas,

My suggestion would be to handle the RadMenu's OnItemClick event and then based on the Text or Value property of your menu item, perform the selected action. To retrieve the row, inside of the OnItemClick event, you would then move up in the parent hierarchy until you reach the RadGridDataItem object. This is what I got to reach the GridDataItem object:

e.Item.Parent.Parent.Parent.Parent

From that you can get the information for that respective row.

I hope that helps.

0
Thomas
Top achievements
Rank 1
answered on 16 Sep 2010, 09:48 AM
Thank you Cori,

That's it.

0
waruni
Top achievements
Rank 1
answered on 08 Dec 2010, 06:45 AM
Hi,

I also have the same scenario.
but i couldn't get the row of the selected menu item.
how should i use this 'e.Item.Parent.Parent.Parent.Parent'.

can any one please help me.

thanks
waruni
0
Thomas
Top achievements
Rank 1
answered on 08 Dec 2010, 07:26 AM
Hi,

this is a snippet from my app:

Telerik.Web.UI.GridDataItem gdi = (Telerik.Web.UI.GridDataItem)e.Item.Parent.Parent.Parent.Parent;
string ProfilId = Convert.ToString(((GridTableView)gdi.NamingContainer).DataKeyValues[gdi.ItemIndex]["cp_id"]);


kind regards

Thomas

 

0
waruni
Top achievements
Rank 1
answered on 08 Dec 2010, 09:08 AM
Hi,

Thanks for the quick reply,
now its work for me :)

thanks a lot
waruni
Tags
Menu
Asked by
Thomas
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Thomas
Top achievements
Rank 1
waruni
Top achievements
Rank 1
Share this question
or