Hello Support,
I use the Grid to Display a Advanced SearchResult in a Tooltip. With the GridButtonColumn, the user should select a Item of the Resultset, in ItemCommand Event the selected Item is set to the selected Value of a ComboBox.
This All works fine, but after selecting a Item with the GridButtonColumn, the Grid highlights the Row, and the GridButtonColumn not displays anymore.
I want to highlight the Row and show the ButtonColumn. If I Rebuild the Grid the Row is not selected anymore, the Button is shown again.
Build the Grid Serverside, is calling after a SearchButton Clicked
| protected void BuildFilterPreviewGrid(ArrayList columnList) |
| { |
| rdgPreview.Columns.Clear(); |
| foreach (string columnName in columnList) |
| { |
| Telerik.Web.UI.GridBoundColumn thisCol = new GridBoundColumn(); |
| thisCol.HeaderText = columnName; |
| thisCol.DataField = columnName; |
| if (columnName == DataValueField) |
| thisCol.Visible = false; |
| rdgPreview.Columns.Add(thisCol); |
| } |
| Telerik.Web.UI.GridButtonColumn thisButtonCol = new GridButtonColumn(); |
| thisButtonCol.UniqueName = "lbtSelect"; |
| thisButtonCol.CommandName = "SelectColumn"; |
| thisButtonCol.Text = "auswählen"; |
| thisButtonCol.ButtonType = GridButtonColumnType.LinkButton; |
| thisButtonCol.Display = true; |
| thisButtonCol.ShowInEditForm = true; |
| rdgPreview.Columns.Add(thisButtonCol); |
| if (DataSource != null) |
| { |
| string RowFilter = string.Empty; |
| if (((List<RowFilterObject>)RowFilterList).Count > 0) |
| RowFilter = RowFilterObject.GetRowFilter((List<RowFilterObject>)RowFilterList); |
| DataSource.DefaultView.RowFilter = (!string.IsNullOrEmpty(RowFilter)) ? "(" + RowFilter + ")" : RowFilter; |
| if (AdvancedFilterString != string.Empty) |
| { |
| if (DataSource.DefaultView.RowFilter != string.Empty) |
| DataSource.DefaultView.RowFilter += " AND (" + AdvancedFilterString + ")"; |
| else |
| DataSource.DefaultView.RowFilter = AdvancedFilterString; |
| } |
| string[] distinctColumns = (string[])columnList.ToArray(typeof(string)); |
| DataTable distinctValues = DataSource.DefaultView.ToTable(true, distinctColumns).Copy(); |
| distinctValues.DefaultView.Sort = DataTextField + " ASC"; |
| rdgPreview.DataSource = distinctValues.DefaultView; |
| rdgPreview.DataBind(); |
| } |
| } |
Grid Events
| void rdgPreview_PageIndexChanged(object source, GridPageChangedEventArgs e) |
| { |
| rdgPreview.CurrentPageIndex = e.NewPageIndex; |
| DoAdvancedFilter(); |
| } |
| void rdgPreview_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName.ToLower() == "selectcolumn") |
| { |
| string arg = e.CommandArgument.ToString(); |
| e.Item.Selected = true; |
| SelectedValue = arg; |
| BuildAdvancedFilterControl(); |
| } |
| } |
| void rdgPreview_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| // GridDataItem dataitem = (GridDataItem)e.Item; |
| System.Web.UI.WebControls.LinkButton thisButton = e.Item.Cells[e.Item.Cells.Count - 1].Controls[0] as System.Web.UI.WebControls.LinkButton; |
| if (thisButton != null) |
| { |
| thisButton.CommandArgument = ((DataRowView)e.Item.DataItem)[DataValueField].ToString(); |
| thisButton.CommandName = "SelectColumn"; |
| } |
| } |
| } |
| <div id="divOuter" runat="server"> |
| <div id="divDropDown" runat="server"> |
| <telerik:RadComboBox ID="ddlDropdown" runat="server" Skin="Gray" Height="190px" AllowCustomText="True" |
| ShowToggleImage="True" ShowMoreResultsBox="true" AutoPostBack="false" EnableLoadOnDemand="True" |
| MarkFirstMatch="false" EnableVirtualScrolling="true" Width="206px" |
| DropDownWidth="450"> |
| </telerik:RadComboBox> |
| <asp:ImageButton ID="btnAdvancedFilter" runat="server" ImageUrl="~/images/icons_32x32_aktiv/filtern.gif" Width="20px" Height="20px" /> |
| </div> |
| <telerik:RadToolTip runat="server" ID="RadToolTip" ShowEvent="OnClick" ManualClose="true" Height="500px" Width="750px" |
| TargetControlID="btnAdvancedFilter" IsClientID="false" OffsetY="4" Delay="1" HideEvent="LeaveToolTip" |
| Animation="Resize" Position="BottomCenter" RelativeTo="Element" Skin="Telerik"> |
| <div style="text-align:left;"> |
| <asp:PlaceHolder ID="plhFilterControls" runat="server"></asp:PlaceHolder> |
| <div style="text-align:right;"> |
| <asp:Button ID="btnDoAdvancedFilter" CssClass="button" runat="server" Text="Filtern"/> <asp:Button ID="btnClear" runat="server" CssClass="button" Text="zurücksetzen"/> |
| </div> |
| <telerik:RadGrid ShowGroupPanel="false" AllowMultiRowSelection="false" AllowMultiRowEdit="false" AutoGenerateColumns="false" ID="rdgPreview" |
| AllowFilteringByColumn="false" AllowSorting="false" width="750px" height="300px" PageSize="10" |
| ShowFooter="false" runat="server" Skin="WebBlue" GridLines="None" AllowPaging="true"> |
| <pagerstyle mode="NextPrevAndNumeric" /> |
| </telerik:RadGrid> |
| </div> |
| </telerik:RadToolTip> |
| <asp:RequiredFieldValidator ID="rvAjaxDropdown" ControlToValidate="ddlDropdown" EnableClientScript="false" |
| runat="server"></asp:RequiredFieldValidator> |
| <telerik:RadToolTipManager runat="server" ID="RadToolTipManager1" Width="750px" Height="500px" |
| RelativeTo="Element" Animation="Slide" Position="BottomCenter" /> |
| </div> |