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

Radgrid Nested View cell values

1 Answer 112 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 13 Jun 2012, 04:24 PM
In My application I populate Nested Rad Grid with three nested tables:
<clients>
<matters>
<files>
</files>
</matters>
</clients

On each level there is a RadioButtonList with three buttons Approve, Assign, Forbid
There are two problems.
How do I populate the Radio Button lists on every level?
What event populates data in the nested views?
Seems easy on the main level, but I cannot make it work on the levels down:

 Protected Sub rgSessionClientsNested_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgSessionClientsNested.ItemDataBound
If e.Item.ItemType = GridItemType.AlternatingItem Or e.Item.ItemType = GridItemType.Item Then
Dim dataItem As GridDataItem = e.Item
Dim radCell As Telerik.Web.UI.GridTableCell = dataItem("authorize")
Dim forbidCell As GridTableCell = dataItem("forbidCnt")
Dim state As String = forbidCell.Text
Dim rdList As System.Web.UI.WebControls.RadioButtonList = radCell.FindControl("RadioButtonListClient1")
If state = "A" Then
rdList.Items(0).Selected = True
ElseIf state = "F" Then
rdList.Items(1).Selected = True
ElseIf state = "N" Then
rdList.Items(2).Selected = True
End If

Second question is related to the first one.
When the user clicks a button on any level I need to trigger a database update.
How can I do it?

Thanks in advance!
Here is my nested grid:

<

 

 

telerik:RadGrid ID="rgSessionClientsNested" runat="server" CellSpacing="0" OnItemCommand="rgSessionClientsNested_ItemCommand"

 

DataSourceID="ObjectDataSource4" GridLines="None" Height="800px">

<

 

 

MasterTableView AutoGenerateColumns="False" DataKeyNames="client_identity"

 

DataSourceID="ObjectDataSource4">

<

 

 

CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<

 

 

RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">

<

 

 

HeaderStyle Width="20px"></HeaderStyle>

</

 

 

RowIndicatorColumn>

<

 

 

ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">

<

 

 

HeaderStyle Width="20px"></HeaderStyle>

</

 

 

ExpandCollapseColumn>

 

<Columns>

 

<telerik:GridBoundColumn DataField="client_identity" DataType="System.Int32"

 

FilterControlAltText="Filter client_identity column"

 

HeaderText="client_identity" ReadOnly="True" SortExpression="client_identity"

 

UniqueName="client_identity">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="client_name"

 

FilterControlAltText="Filter client_name column" HeaderText="client_name"

 

SortExpression="client_name" UniqueName="client_name">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="client_id"

 

FilterControlAltText="Filter client_id column" HeaderText="client_id"

 

SortExpression="client_id" UniqueName="client_id">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="address_1"

 

FilterControlAltText="Filter address_1 column" HeaderText="address_1"

 

SortExpression="address_1" UniqueName="address_1">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="address_2"

 

FilterControlAltText="Filter address_2 column" HeaderText="address_2"

 

SortExpression="address_2" UniqueName="address_2">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="notes"

 

FilterControlAltText="Filter notes column" HeaderText="notes"

 

SortExpression="notes" UniqueName="notes">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="forbidCnt"

 

FilterControlAltText="Filter forbidCnt column" HeaderText="forbidCnt"

 

ReadOnly="True" SortExpression="forbidCnt" UniqueName="forbidCnt">

 

</telerik:GridBoundColumn>

 

<telerik:GridTemplateColumn HeaderText="authorize" UniqueName="authorize">

 

<ItemTemplate>

 

<asp:RadioButtonList id="RadioButtonListClient1" AutoPostBack="True" RepeatDirection="Horizontal" runat="server">

 

<asp:ListItem Text="approve" Value="A" Selected="False" />

 

<asp:ListItem Text="forbid" Value="F" Selected="False" />

 

<asp:ListItem Text="assign" Value="N" Selected="False" />

 

</asp:RadioButtonList>

 

</ItemTemplate>

 

</telerik:GridTemplateColumn>

 

</Columns>

 

<NestedViewSettings runat="server"

 

DataSourceID="ObjectDataSource5">

 

<ParentTableRelation>

 

<telerik:GridRelationFields DetailKeyField="client_identity" MasterKeyField="client_identity" />

 

</ParentTableRelation>

 

</NestedViewSettings>

 

<NestedViewTemplate>

 

<telerik:RadGrid ID="rgSessionMattersNested" runat="server" CellSpacing="0"

 

DataSourceID="ObjectDataSource5" GridLines="None" >

<

 

 

MasterTableView AutoGenerateColumns="False" DataKeyNames="matter_id" DataSourceID="ObjectDataSource5">

<

 

 

CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<

 

 

RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">

<

 

 

HeaderStyle Width="20px"></HeaderStyle>

</

 

 

RowIndicatorColumn>

<

 

 

ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">

<

 

 

HeaderStyle Width="20px"></HeaderStyle>

</

 

 

ExpandCollapseColumn>

 

<Columns>

 

<telerik:GridBoundColumn DataField="matter_id" DataType="System.Int32"

 

FilterControlAltText="Filter matter_id column" HeaderText="Matter Id"

 

ReadOnly="True" SortExpression="matter_id" UniqueName="matter_id" Visible="False">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="matter_num"

 

FilterControlAltText="Filter matter_num column" HeaderText="Matter Number"

 

SortExpression="matter_num" UniqueName="matter_num">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="matter_name"

 

FilterControlAltText="Filter matter_name column" HeaderText="Matter Name"

 

SortExpression="matter_name" UniqueName="matter_name">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="abstract"

 

FilterControlAltText="Filter abstract column" HeaderText="Abstract"

 

SortExpression="abstract" UniqueName="abstract">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="destroy_after" DataType="System.DateTime"

 

FilterControlAltText="Filter destroy_after column" HeaderText="Destroy After"

 

SortExpression="destroy_after" UniqueName="destroy_after">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="client_identity" DataType="System.Int32"

 

FilterControlAltText="Filter client_identity column"

 

HeaderText="client_identity" SortExpression="client_identity"

 

UniqueName="client_identity" Visible="False">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="forbidCnt"

 

FilterControlAltText="Filter forbidCnt column" HeaderText="forbidCnt"

 

ReadOnly="True" SortExpression="forbidCnt" UniqueName="forbidCnt" Visible="False">

 

</telerik:GridBoundColumn>

 

<telerik:GridTemplateColumn HeaderText="authorize" UniqueName="Authorize">

 

<ItemTemplate>

 

<asp:RadioButtonList id="RadioButtonListClient2" AutoPostBack="True" RepeatDirection="Horizontal" runat="server">

 

<asp:ListItem Text="approve" Value="A" Selected="False" />

 

<asp:ListItem Text="forbid" Value="F" Selected="False" />

 

<asp:ListItem Text="assign" Value="N" Selected="False" />

 

</asp:RadioButtonList>

 

</ItemTemplate>

 

</telerik:GridTemplateColumn>

 

</Columns>

 

<NestedViewSettings runat="server"

 

DataSourceID="ObjectDataSource6">

 

<ParentTableRelation>

 

<telerik:GridRelationFields DetailKeyField="matter_id" MasterKeyField="matter_id" />

 

</ParentTableRelation>

 

</NestedViewSettings>

 

<NestedViewTemplate>

<

 

 

telerik:RadGrid ID="rgSessionFilesNested" runat="server" CellSpacing="0"

 

DataSourceID="ObjectDataSource6" GridLines="None">

<

 

 

MasterTableView AutoGenerateColumns="False" DataKeyNames="file_id" DataSourceID="ObjectDataSource6">

<

 

 

CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<

 

 

RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">

<

 

 

HeaderStyle Width="20px"></HeaderStyle>

</

 

 

RowIndicatorColumn>

<

 

 

ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">

<

 

 

HeaderStyle Width="20px"></HeaderStyle>

</

 

 

ExpandCollapseColumn>

 

<Columns>

 

<telerik:GridBoundColumn DataField="file_id" DataType="System.Int32"

 

FilterControlAltText="Filter file_id column" HeaderText="File Id"

 

ReadOnly="True" SortExpression="file_id" UniqueName="file_id" Visible="False">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="file_number"

 

FilterControlAltText="Filter file_number column" HeaderText="File Number"

 

ReadOnly="True" SortExpression="file_number" UniqueName="file_number">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="subfile_desc"

 

FilterControlAltText="Filter subfile_desc column" HeaderText="File Name"

 

SortExpression="subfile_desc" UniqueName="subfile_desc">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="title"

 

FilterControlAltText="Filter title column" HeaderText="File Status"

 

SortExpression="title" UniqueName="title">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="redweld_id" DataType="System.Int32"

 

FilterControlAltText="Filter redweld_id column" HeaderText="redweld_id"

 

SortExpression="redweld_id" UniqueName="redweld_id" Visible="False">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="FileType"

 

FilterControlAltText="Filter FileType column" HeaderText="File Type"

 

SortExpression="FileType" UniqueName="FileType">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="matter_id" DataType="System.Int32"

 

FilterControlAltText="Filter matter_id column" HeaderText="matter_id"

 

SortExpression="matter_id" UniqueName="matter_id" Visible="False">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="redweld_num" DataType="System.Int32"

 

FilterControlAltText="Filter redweld_num column" HeaderText="Redweld Number"

 

ReadOnly="True" SortExpression="redweld_num" UniqueName="redweld_num">

 

</telerik:GridBoundColumn>

 

<telerik:GridBoundColumn DataField="forbidCnt"

 

FilterControlAltText="Filter forbidCnt column" HeaderText="forbidCnt"

 

SortExpression="forbidCnt" UniqueName="forbidCnt" Visible="False">

 

</telerik:GridBoundColumn>

 

<telerik:GridTemplateColumn HeaderText="Authorize" UniqueName="authorize">

 

<ItemTemplate>

 

<asp:RadioButtonList id="RadioButtonListClient3" AutoPostBack="True" RepeatDirection="Horizontal" runat="server">

 

<asp:ListItem Text="approve" Value="A" Selected="False" />

 

<asp:ListItem Text="forbid" Value="F" Selected="False" />

 

<asp:ListItem Text="assign" Value="N" Selected="False" />

 

</asp:RadioButtonList>

 

</ItemTemplate>

 

</telerik:GridTemplateColumn>

 

</Columns>

<

 

 

EditFormSettings>

<

 

 

EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>

</

 

 

EditFormSettings>

</

 

 

MasterTableView>

<

 

 

FilterMenu EnableImageSprites="False">

<

 

 

WebServiceSettings>

<

 

 

ODataSettings InitialContainerName=""></ODataSettings>

</

 

 

WebServiceSettings>

</

 

 

FilterMenu>

<

 

 

HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">

<

 

 

WebServiceSettings>

<

 

 

ODataSettings InitialContainerName=""></ODataSettings>

</

 

 

WebServiceSettings>

</

 

 

HeaderContextMenu>

 

</telerik:RadGrid>

 

</NestedViewTemplate>

<

 

 

EditFormSettings>

<

 

 

EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>

</

 

 

EditFormSettings>

</

 

 

MasterTableView>

<

 

 

FilterMenu EnableImageSprites="False">

<

 

 

WebServiceSettings>

<

 

 

ODataSettings InitialContainerName=""></ODataSettings>

</

 

 

WebServiceSettings>

</

 

 

FilterMenu>

<

 

 

HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">

<

 

 

WebServiceSettings>

<

 

 

ODataSettings InitialContainerName=""></ODataSettings>

</

 

 

WebServiceSettings>

</

 

 

HeaderContextMenu>

 

</telerik:RadGrid>

 

</NestedViewTemplate>

<

 

 

EditFormSettings>

<

 

 

EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>

</

 

 

EditFormSettings>

</

 

 

MasterTableView>

<

 

 

FilterMenu EnableImageSprites="False">

<

 

 

WebServiceSettings>

<

 

 

ODataSettings InitialContainerName=""></ODataSettings>

</

 

 

WebServiceSettings>

</

 

 

FilterMenu>

<

 

 

HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">

<

 

 

WebServiceSettings>

<

 

 

ODataSettings InitialContainerName=""></ODataSettings>

</

 

 

WebServiceSettings>

</

 

 

HeaderContextMenu>

 

</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 18 Jun 2012, 08:04 AM
Hello,

 One way to populate the RaddioButtonList is programmatically in the ItemDataBound event of the related grid. There you can access the RadioButtonList by first accessing the cell and then using the FindControl method. There you also have access to the data coming from the datasource (through e.Item.DataItem property) which you can use to bind the correct selected value of the RadioButtonList.
As for the populating of the NestedViews when there is a more complex control in it (such as RadGrid) you need another approach different than the ParentTableRelations in the NestedViewSettings. In order to filter correctly the datasource of the inner grid - you have to add a control parameter to its where clause - (for example from a hidden label) as shown in this demo with the EmployeeID parameter of the inner grid.

Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Joseph
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or