Hi all,
I am working with a RadGrid with a NestedView that has Client row-selecting enabled and has EnablePostBackOnRowClick set to True. When I attempt to expand a row (either by the Client "RowClick" or by using the expand column), I am handling the ItemCommand event server side to attempt to close any currently expanded rows, and expand only the currently clicked row (like in the "Overview" demo for the RadGrid). Here is the RadGrid:
And here is the ItemCommand event handler:
If I was to only click on the expand/collapse column to open the rows, I would have no issue and the Grid would behave as I expect. But if I click on a row (which should expand that Row's NestedView), I see that the following uncaught exception is displayed in my browser's console:
"Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: DataBinding: 'ToString()' is not a valid indexed expression."
If, however, I change AllowRowSelect to be set to False (while leaving EnablePostbackOnRowClick set to True), the program works as I would expect (when clicking the expand/collapse column or clicking the row).
While I could probably work with this, I'm wondering why it is not working when AllowRowSelect is set to True. (Also, the default styling for the SelectedRow is not applied when AllowRowSelect is set to False).
I'm fairly new to Telerik's controls, so I may be missing something obvious, but thanks for any help/suggestions.
I am working with a RadGrid with a NestedView that has Client row-selecting enabled and has EnablePostBackOnRowClick set to True. When I attempt to expand a row (either by the Client "RowClick" or by using the expand column), I am handling the ItemCommand event server side to attempt to close any currently expanded rows, and expand only the currently clicked row (like in the "Overview" demo for the RadGrid). Here is the RadGrid:
<telerik:RadGrid ID="gridShipmentsToBill" runat="server" Width="100%" DataSourceID="ShipmentsToBill" AllowSorting="True" AutoGenerateColumns="False" GridLines="Vertical"> <ClientSettings EnablePostBackOnRowClick="true" EnableRowHoverStyle="True"> <Scrolling AllowScroll="True" ScrollHeight="500px" UseStaticHeaders="true"></Scrolling> <Selecting AllowRowSelect="true" /> </ClientSettings> <MasterTableView HierarchyLoadMode="ServerBind" DataKeyNames="Shipment_Key" DataSourceID="ShipmentsToBill" RetainExpandStateOnRebind="false"> <Columns> <telerik:GridBoundColumn DataField="Shipment_Key" ReadOnly="True" HeaderText="CPU #" SortExpression="Shipment_Key" UniqueName="Shipment_Key"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Shipment_AWorBOL" HeaderText="AWB/BOL #" SortExpression="Shipment_AWorBOL" UniqueName="Shipment_AWorBOL"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Customer_Name" HeaderText="Customer" SortExpression="Customer_Name" UniqueName="Customer_Name"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Shipment_Description" HeaderText="Description" SortExpression="Shipment_Description" UniqueName="Shipment_Description"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Voyage_ArriveDate" HeaderText="Arrival Date" SortExpression="Voyage_ArriveDate" DataFormatString="{0:MM/dd/yyyy}" UniqueName="Voyage_ArriveDate" DataType="System.DateTime"> </telerik:GridBoundColumn> </Columns> <NestedViewSettings DataSourceID="GeneralShipmentData"> <ParentTableRelation> <telerik:GridRelationFields MasterKeyField="Shipment_Key" DetailKeyField="Shipment_Key"></telerik:GridRelationFields> </ParentTableRelation> </NestedViewSettings> <NestedViewTemplate> <div class="generalInfoForm"> <div class="leftForm"> <span> <label>Customer:</label> <%# Eval("Customer_Num")%> <%# Eval("Customer_Name") %></span> <span> <label>Consignee:</label> <%# Eval("Consignee_Num")%> <%# Eval("Consignee_Name") %></span> <span> <label>Arrival Date:</label> <%# Eval("Voyage_ArriveDate", "{0:MM/dd/yyyy}")%></span> </div> <div class="rightForm"> <span> <label>AWB/BOL:</label> <%# Eval("Shipment_AWorBOL")%></span> <span> <label>Carrier:</label> <%# Eval("Carrier_Name")%></span> <span> <label>Vessel:</label> <%# Eval("Vessel_Name") %></span> <span> <label>Forwarding Agent:</label> <%# Eval("ForwardingAgent_Name") %></span> </div> <div class="middleForm"><%# Eval("Shipment_Description")%></div> <div class="leftForm"> <span> <label>Volume Weight:</label> <%# Eval("ShipPackage_VolumeWeight")%></span> <span> <label>Weight:</label> <%# Eval("ShipPackage_TotalWeight")%></span> <span> <label>Cube:</label> <%# Eval("ShipPackage_TotalVolume")%></span> <span> <label>Freight:</label> <%# Eval("ShipmentCover_FaceFreight")%></span> </div> </div> </NestedViewTemplate> </MasterTableView> </telerik:RadGrid>Protected Sub gridShipmentsToBill_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles gridShipmentsToBill.ItemCommand If e.CommandName = "RowClick" OrElse e.CommandName = RadGrid.ExpandCollapseCommandName Then Dim previousState As Boolean = e.Item.Expanded If e.CommandName = "ExpandCollapse" Then previousState = Not previousState End If CollapseAllRows() e.Item.Expanded = Not previousState End If End Sub Private Sub CollapseAllRows() For Each item As GridItem In gridShipmentsToBill.MasterTableView.Items item.Expanded = False Next End SubIf I was to only click on the expand/collapse column to open the rows, I would have no issue and the Grid would behave as I expect. But if I click on a row (which should expand that Row's NestedView), I see that the following uncaught exception is displayed in my browser's console:
"Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: DataBinding: 'ToString()' is not a valid indexed expression."
If, however, I change AllowRowSelect to be set to False (while leaving EnablePostbackOnRowClick set to True), the program works as I would expect (when clicking the expand/collapse column or clicking the row).
While I could probably work with this, I'm wondering why it is not working when AllowRowSelect is set to True. (Also, the default styling for the SelectedRow is not applied when AllowRowSelect is set to False).
I'm fairly new to Telerik's controls, so I may be missing something obvious, but thanks for any help/suggestions.