4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 04 Jul 2013, 12:41 PM
Hi Jay,
Please refer to the following link for your requirement.Hope this helps you.
http://www.telerik.com/community/forums/aspnet-ajax/grid/access-to-radgrid-in-nestedviewtemplate-in-client-side-code.aspx#816098
Thanks,
Princy
Please refer to the following link for your requirement.Hope this helps you.
http://www.telerik.com/community/forums/aspnet-ajax/grid/access-to-radgrid-in-nestedviewtemplate-in-client-side-code.aspx#816098
Thanks,
Princy
0
Jay
Top achievements
Rank 1
answered on 04 Jul 2013, 07:07 PM
Hi Princy,
Thank you for your reply. i went through the sample code which you have suggested, but my scenario is different. i have radgrid and a textbox control in nestedviestemplate. i am binding the grid through client side. after binding i need to expand/collapse the nestedviewtemplate based on the value present in textbox in OnDataBound client event. e.g: if data is present in textbox 'txtError' then i have to expand else i need to hide the nestedviewtemplate for that row.
1) how to find the control in nestedviewtemplate?
2) how to show/hide nestedviewtemplate based on the value of textbox. screen shot attached shows how exactly i need to implement.
below is the OnDataBound Event
Thank you,
Jai
Thank you for your reply. i went through the sample code which you have suggested, but my scenario is different. i have radgrid and a textbox control in nestedviestemplate. i am binding the grid through client side. after binding i need to expand/collapse the nestedviewtemplate based on the value present in textbox in OnDataBound client event. e.g: if data is present in textbox 'txtError' then i have to expand else i need to hide the nestedviewtemplate for that row.
1) how to find the control in nestedviewtemplate?
2) how to show/hide nestedviewtemplate based on the value of textbox. screen shot attached shows how exactly i need to implement.
below is the OnDataBound Event
function
OnDataBound(sender, args) {
var
master_tblView = $find(
"<%= grdTestApp.ClientID %>"
).get_masterTableView();
for
(
var
i = 0; i < master_tblView.get_dataItems().length; i++) {
var
item = master_tblView.get_dataItems()[i];
if
(item.get_nestedViews().length > 0) {
// need to find the textbox control and if data is present then nestedviewtemplate should be displayed
// else it needs to be hidden
}
}
}
<
telerik:RadGrid
ID
=
"grdTestApp"
runat
=
"server"
PageSize
=
"10"
AllowPaging
=
"true"
ExportSettings-IgnorePaging
=
"true"
ExportSettings-OpenInNewWindow
=
"true"
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
>
<
Resizing
AllowResizeToFit
=
"true"
AllowColumnResize
=
"true"
/>
<
Scrolling
AllowScroll
=
"true"
ScrollHeight
=
""
UseStaticHeaders
=
"true"
/>
<
ClientEvents
OnCommand
=
"grdTestApp_Command"
OnDataBound
=
"OnDataBound"
/>
</
ClientSettings
>
<
MasterTableView
Width
=
"100%"
TableLayout
=
"Fixed"
AutoGenerateColumns
=
"false"
CommandItemDisplay
=
"Top"
HierarchyLoadMode
=
"Client"
CommandItemSettings-ShowExportToPdfButton
=
"true"
>
<
CommandItemTemplate
>
<
asp:ImageButton
ID
=
"btnPdf"
runat
=
"server"
ImageUrl
=
"~/IMAGES/ExportPDF.jpg"
OnClick
=
"btnPdf_Click"
/>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"120"
FilterControlWidth
=
"68px"
DataField
=
"ContainerId"
HeaderStyle-Font-Bold
=
"true"
HeaderText
=
"ContainerId"
UniqueName
=
"ContainerId"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"120"
FilterControlWidth
=
"68px"
DataField
=
"ContainerNumber"
HeaderStyle-Font-Bold
=
"true"
HeaderText
=
"ContainerNumber"
UniqueName
=
"ContainerNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"120"
FilterControlWidth
=
"68px"
DataField
=
"SCAC"
HeaderStyle-Font-Bold
=
"true"
HeaderText
=
"SCAC"
UniqueName
=
"SCAC"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"120"
FilterControlWidth
=
"68px"
DataField
=
"EquipmentType"
HeaderStyle-Font-Bold
=
"true"
HeaderText
=
"EquipmentType"
UniqueName
=
"EquipmentType"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"120"
FilterControlWidth
=
"68px"
DataField
=
"EQDescription"
HeaderStyle-Font-Bold
=
"true"
HeaderText
=
"EQDescription"
UniqueName
=
"EQDescription"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"120"
FilterControlWidth
=
"68px"
DataField
=
"RFIDTagNumber"
HeaderStyle-Font-Bold
=
"true"
HeaderText
=
"RFIDTagNumber"
UniqueName
=
"RFIDTagNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"120"
FilterControlWidth
=
"68px"
DataField
=
"CreateDate"
HeaderStyle-Font-Bold
=
"true"
HeaderText
=
"CreateDate"
UniqueName
=
"CreateDate"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"120"
FilterControlWidth
=
"68px"
DataField
=
"ContainerNumberNoCD"
HeaderStyle-Font-Bold
=
"true"
HeaderText
=
"ContainerNumberNoCD"
UniqueName
=
"ContainerNumberNoCD"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
NestedViewTemplate
>
<
asp:TextBox
ID
=
"txtError"
runat
=
"server"
Text
=
"Jai"
></
asp:TextBox
>
</
NestedViewTemplate
>
</
MasterTableView
>
</
telerik:RadGrid
>
Thank you,
Jai
0
Accepted
Hi Jai,
You could use the OnRowDataBound client event to get the value of the TextBox and expand the row if necessary.
I am attaching a sample project illustrating RadGrid with client-side binding and NestedViewTemplate with a TextBox control. In the sample OnRowDataBound only the rows with odd numbers are expanded.
Give this approach a try and you should get the results you are looking for.
Regards,
Viktor Tachev
Telerik
You could use the OnRowDataBound client event to get the value of the TextBox and expand the row if necessary.
I am attaching a sample project illustrating RadGrid with client-side binding and NestedViewTemplate with a TextBox control. In the sample OnRowDataBound only the rows with odd numbers are expanded.
Give this approach a try and you should get the results you are looking for.
Regards,
Viktor Tachev
Telerik
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 the blog feed now.
0
Jay
Top achievements
Rank 1
answered on 10 Jul 2013, 08:51 AM
Hi Viktor,
Thanks for reply, your example works great.
Thank you once again.
Jai