Hi there.
I have a RadGrid that has Master/Detail tables in it. I have purposely removed the expand/collapse column and made the grid expand/collapse when the row is selected (on item command). My grid is a single select grid, but when I select a master table row, then scroll so that the selected row is no longer visible, then select another row, the grid has 2 rows selected. This does not occur when I select multiple rows on the same viewable region in the grid. I am coding around this issue right now, by looking to see if the selected row count is > 1, then clearing the selection appropriately. I obviously have something setup incorrectly. Any ideas?
Here is my relevant code-behind code:
| override protected void OnInit(EventArgs e) |
| { |
| this.Load += new System.EventHandler(this.Page_Load); |
| this.rgT.NeedDataSource += new GridNeedDataSourceEventHandler(this.rgTask_NeedDataSource); |
| this.rgT.DetailTableDataBind += new GridDetailTableDataBindEventHandler(this.rgT_DetailDataBind); |
| this.cbOperators.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cbOperators_SelectedIndexChanged); |
| this.rgT.ItemDataBound += new GridItemEventHandler(rgT_ItemDataBound); |
| this.rgT.ItemCommand += new GridCommandEventHandler(rgT_ItemCommand); |
| this.btnAddTask.Click += new EventHandler(this.btnAddTask_Click); |
| this.btnEdit.Click += new EventHandler(this.btnEdit_Click); |
| this.btnDelete.Click += new EventHandler(this.btnDelete_Click); |
| this.btnQualifiers.Click += new EventHandler(this.btnQualifiers_Click); |
| this.btnBack.Click += new EventHandler(this.btnBack_Click); |
| this.btnBulkLoad.Click += new EventHandler(this.btnBulkLoad_Click); |
| base.OnInit(e); |
| } |
| protected void rgT_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == "RowClick") |
| { |
| // row is selected, enable appropriate buttons |
| EnableButtons(true); |
| // toggle the row expansion |
| GridDataItem item = (GridDataItem)e.Item; |
| item.Expanded = !item.Expanded; |
| } |
| } |
| protected void rgT_DetailDataBind(object source, GridDetailTableDataBindEventArgs e) |
| { |
| GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem; |
| if (rgT.SelectedItems.Count > 0) |
| { |
| long TaskId = (long)rgT.MasterTableView.DataKeyValues[rgT.SelectedItems[0].ItemIndex]["TaskId"]; |
| e.DetailTableView.DataSource = BLQualifierSet.SelectQualifiersByTask(TaskId); |
| } |
| } |
My grid:
| <telerik:RadGrid ID="rgT" runat="server" GridLines="None" |
| AutoGenerateColumns="False" AllowSorting="True" |
| Width="100%" AllowMultiRowSelection="false"> |
| <MasterTableView CellSpacing="-1" DataKeyNames="TaskId" TableLayout="Fixed" ExpandCollapseColumn-Display="False"> |
| <Columns> |
| <telerik:GridBoundColumn DataField="Number" UniqueName="colNumber" HeaderText="Number" HeaderStyle-Width="5%"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Name" UniqueName="colName" HeaderText="Title" HeaderStyle-Width="85%"> |
| </telerik:GridBoundColumn> |
| <telerik:GridTemplateColumn DataField="SpanControlRatio" HeaderText="SOC" HeaderStyle-Width="10%" |
| UniqueName="colSpanControlRatio"> |
| <ItemTemplate> |
| <asp:Label ID="lblSOCRatio" runat="server" |
| Text='<%# Eval("SpanControlRatio") %>'></asp:Label> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| <DetailTables> |
| <telerik:GridTableView DataKeyNames="QualifierSetID" Name="QualifierSets" Width="100%" TableLayout="Fixed"> |
| <ParentTableRelation> |
| <telerik:GridRelationFields DetailKeyField="TaskId" MasterKeyField="TaskId" /> |
| </ParentTableRelation> |
| <Columns> |
| <telerik:GridTemplateColumn HeaderStyle-Width="5%" ItemStyle-ForeColor="Red"> |
| <ItemTemplate><asp:Label id="rowNum" runat="server"></asp:Label> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn HeaderText="Provider" DataField="ProviderName" DataType="System.String" HeaderStyle-Width="15%"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Evaluations" DataField="QualifierName" DataType="System.String" HeaderStyle-Width="55%"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Method" DataField="QualifierType" DataType="System.String" HeaderStyle-Width="10%"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Re-Evaluation Frequency" DataField="ReevaluationFrequency" HeaderStyle-Width="15%" DataType="System.Int32"></telerik:GridBoundColumn> |
| </Columns> |
| <GroupByExpressions> |
| <telerik:GridGroupByExpression> |
| <GroupByFields> |
| <telerik:GridGroupByField FieldName="QualifierSetId" /> |
| </GroupByFields> |
| <SelectFields> |
| <telerik:GridGroupByField FieldName="EmptyString" HeaderText="Evaluation Set" HeaderValueSeparator=" "/> |
| </SelectFields> |
| </telerik:GridGroupByExpression> |
| </GroupByExpressions> |
| </telerik:GridTableView> |
| </DetailTables> |
| </MasterTableView> |
| <ClientSettings EnablePostBackOnRowClick="true"> |
| <Selecting AllowRowSelect="True" /> |
| <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="300px"/> |
| </ClientSettings> |
| </telerik:RadGrid> |