I'm having a couple problems with NestedViewTemplates in RadGrid. I have enabled PostbackOnRowClick for the grid and assigned an OnItemCommand to the RadGrid so that I can execute code when the row is expanded. The problem is, the command seems to execute twice when the user clicks on the ExpandCollapse button. Once for "ExpandCollapse" command and once for "RowClick". What I'd like is for either an ExpandCollapse OR a RowClick to execute the ItemCommand method, and then stop, rather than executing it again. Is there a way to do this?
Also, how do I capture the "Expand" event on the client side? And is it possible to hide the ExpandCollapse column in a NetsedViewTemplate? As you can see from my code, I've tried just about everything to hide it but nothing seems to work...
Here's a code sample of what I'm doing:
Thanks for the help!
Eddie
Also, how do I capture the "Expand" event on the client side? And is it possible to hide the ExpandCollapse column in a NetsedViewTemplate? As you can see from my code, I've tried just about everything to hide it but nothing seems to work...
Here's a code sample of what I'm doing:
| <telerik:RadGrid runat="server" ID="radGridWts" GridLines="Horizontal" |
| AutoGenerateColumns="false" EnableAjaxSkinRendering="True" Skin="Office2007" |
| ClientSettings-EnableRowHoverStyle="true" OnItemCommand="radGridWts_ItemCommand" |
| OnItemDataBound="radGridWts_ItemDataBound" ShowDesignTimeSmartTagMessage="true"> |
| <ClientSettings EnablePostBackOnRowClick="True" AllowExpandCollapse="false"> |
| <Resizing AllowColumnResize="true" ResizeGridOnColumnResize="false" EnableRealTimeResize="true" /> |
| </ClientSettings> |
| <MasterTableView DataKeyNames="WtID,WtRid"> |
| <ExpandCollapseColumn Display="false" Visible="false"> |
| <HeaderStyle Width="0px" /> |
| <ItemStyle Width="0px" /> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <Columns> |
| <telerik:GridBoundColumn HeaderText="WtID" Visible="False" HeaderStyle-HorizontalAlign="Left" DataField="WtID" UniqueName="colWtId"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Sev" HeaderStyle-HorizontalAlign="Left" DataField="Severity"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="RID" DataField="WtRid"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Wt Number" DataField="WtNumber" ></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Date" DataField="DateIssued" DataFormatString="{0:d}"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Type" DataField="WtType"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Section" DataField="WtCode"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Bail Amount" DataField="BailAmount" DataFormatString="{0:C}" UniqueName="colBailAmt"></telerik:GridBoundColumn> |
| </Columns> |
| <NestedViewTemplate> |
| <div style="padding:5px;"> |
| <div id="buttons"> |
| <a style="float:right; margin-left:-155px; margin-top:5px; position:absolute" |
| href="" tabindex="32" onmouseup="javascript:window.focus()" |
| onclick="javascript:CopyWtDetails('<%= strCopyWtDetails %>');return false;" class="copy"></a> |
| </div> |
| <asp:Label runat="server" ID="lblWtDetail"></asp:Label> |
| <div style="border-top: 1px solid #ccc; padding-top: 5px;"> |
| <telerik:RadPanelBar runat="server" ID="rPanelBarDdVisits" Width="100%" EnableEmbeddedSkins="false" |
| Skin="Hay" ExpandAnimation-Type="InBounce" OnClientItemClicking="OnClientItemClicking"> |
| <Items> |
| <telerik:RadPanelItem runat="server" Text="Due Diligence" Expanded="false" ExpandedImageUrl="../images/submenu_dn.gif" |
| ImageUrl="../images/submenu.gif"> |
| <Items> |
| <telerik:RadPanelItem runat="server"> |
| <ItemTemplate> |
| <div style="margin: 3px 0px 1px 0px;"> |
| <telerik:RadGrid runat="server" ID="rGridDdVisits" Skin="Office2007" AutoGenerateColumns="false"> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridBoundColumn HeaderText="DATE" DataField="CommentDate" DataFormatString="{0:d}"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="DESCRIPTION" DataField="Comment"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="LEA" DataField="Lea"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="OFFICER" DataField="Officer"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </div> |
| </ItemTemplate> |
| </telerik:RadPanelItem> |
| </Items> |
| </telerik:RadPanelItem> |
| </Items> |
| </telerik:RadPanelBar> |
| </div> |
| </div> |
| </NestedViewTemplate> |
| </MasterTableView> |
| </telerik:RadGrid> |
| protected void radGridWts_ItemCommand(object sender, GridCommandEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| string strWtID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["WtID"].ToString(); |
| string strRid = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["WtRid"].ToString(); |
| if (e.CommandName == "RowClick" || e.CommandName == "ExpandCollapse") |
| if (!e.Item.Expanded) |
| { |
| e.Item.Expanded = true; |
| e.Item.Selected = true; |
| Wt w = Wt.getWtDetails(strWtID, strRid); |
| if (w != null) |
| { |
| strCopyWtDetails = BuildCopyWtDetails(w); |
| Label lblWtDetail; |
| GridNestedViewItem nviWtDetails = |
| ((GridTableView)e.Item.Parent.Parent).Items[e.Item.ItemIndex].ChildItem; |
| lblWtDetail = nviWtDetails.FindControl("lblWtDetail") as Label; |
| RadPanelBar rpb = nviWtDetails.FindControl("rPanelBarDueDiligence") as RadPanelBar; |
| if (w.DdVisits != null && w.DdVisits.Count > 0) |
| { |
| if (rpb != null) |
| if (rpb.Items[0].Text.IndexOf("(") < 0) |
| rpb.Items[0].Text += " (" + w.DdVisits.Count + ")"; |
| RadGrid rGridDdVisits = |
| nviWtDetails.FindControl("rPanelBarDueDiligence").Controls[0].Controls[0]. |
| FindControl("rGridDueDiligence") as RadGrid; |
| if (rGridDdVisits != null) |
| { |
| rGridDdVisits.DataSource = w.DdVisits; |
| rGridDdVisits.DataBind(); |
| } |
| } |
| else if (w.DdVisits == null || w.DdVisits.Count < 1) if (rpb != null) rpb.Visible = false; |
| if (lblWtDetail != null) |
| lblWtDetail.Text = WriteWtDetails(w).ToString(); |
| } |
| } |
| else |
| e.Item.Expanded = false; |
| } |
| } |
Thanks for the help!
Eddie