Hello,
I'm using a grid in which I'm implementing custom filtering as shown in the documentation and in the online demos, but I'm having some difficulties in making it work properly.
My grid is defined as follows (to try and make it clearer, I'm only copying the impacted column):
This grid is contained in a user control, which is contained in another user control, as follows (ucBusinessRoles is the user control containing the grid):
The RadComboBox used for filtering is bound to a dictionary, as follows:
And the whole grid is bound in the NeedDataSource event.
The grid is displayed correctly and the drop-down list is populated correctly, but if I select a in the drop-down list to filter by it, then the grid refreshes and all the records are "filtered" (so it doesn't matter which value I select for filtering: I will always get no results, even if the list contains valid items), so the filtered grid will always be empty (see attachments).
I've tried several approaches and followed the tutorials and demos, but I couldn't get this working.
What am I doing wrong?
Thanks in advance.
I'm using a grid in which I'm implementing custom filtering as shown in the documentation and in the online demos, but I'm having some difficulties in making it work properly.
My grid is defined as follows (to try and make it clearer, I'm only copying the impacted column):
<telerik:RadGrid ID="grdBusinessRoles" runat="server" AllowMultiRowSelection="false" AllowFilteringByColumn="true" ShowFooter="false" AllowSorting="True" AutoGenerateColumns="False" AllowPaging="true"> <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" TableLayout="Auto" CommandItemDisplay="Top" DataKeyNames="BusinessRoleId2,BusinessRoleId" PageSize="15"> <CommandItemTemplate> <asp:LinkButton runat="server" ID="btnClear" Text="Clear Filters" CommandName="ClearFilters" /> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn UniqueName="colStream" DataField="StreamName" HeaderText="Stream" SortExpression="StreamName" ReadOnly="true"> <FilterTemplate> <telerik:RadComboBox ID="rcbStreams" DataTextField="Value" DataValueField="Value" AppendDataBoundItems="true" AutoPostBack="false" SelectedValue='<%# TryCast(Container, GridItem).OwnerTableView.GetColumn("colStream").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="SelectedIndexChanged"> <Items> <telerik:RadComboBoxItem /> </Items> </telerik:RadComboBox> <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> <script type="text/javascript"> function SelectedIndexChanged(sender, args) { var tableView = $find("<%# TryCast(Container, GridItem).OwnerTableView.ClientID %>"); tableView.filter("colStream", args.get_item().get_value(), "EqualTo"); } </script> </telerik:RadScriptBlock> </FilterTemplate> </telerik:GridBoundColumn> </Columns> <NoRecordsTemplate> <asp:Label runat="server" ID="lblNoRecords" Text="No Business Roles found."></asp:Label> </NoRecordsTemplate> <PagerStyle PageSizeControlType="RadComboBox" /> </MasterTableView> <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> <FilterMenu EnableImageSprites="False"> </FilterMenu> <ClientSettings EnableRowHoverStyle="true"> <Selecting AllowRowSelect="true" /> </ClientSettings></telerik:RadGrid>This grid is contained in a user control, which is contained in another user control, as follows (ucBusinessRoles is the user control containing the grid):
<!-- Select Business Roles --><telerik:RadWindow runat="server" ID="wdwBusinessRoles" Modal="true" Width="820px" Height="500px" Behaviors="Close" CssClass="RadWindow_Pram"> <ContentTemplate> <telerik:RadAjaxPanel ID="pnlBusinessRoles" runat="server"> <pram:ucBusinessRoles ID="ucSelectBusinessRole" runat="server" TypeOfList="AssignRoleVariants" TypeOfSelection="SingleSelection" AllowNavigation="False" AllowNewBusinessRole="False" /> </telerik:RadAjaxPanel> <telerik:RadButton ID="btnAddRolesToList" runat="server" Text="Select Role" CssClass="RadButton_Pram submit" /> </ContentTemplate></telerik:RadWindow>The RadComboBox used for filtering is bound to a dictionary, as follows:
Protected Sub grdBusinessRoles_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) _ Handles grdBusinessRoles.ItemCreated If TypeOf (e.Item) Is GridFilteringItem Then Dim filterItem As GridFilteringItem = CType(e.Item, GridFilteringItem) Dim combo As RadComboBox = CType(filterItem("colStream").FindControl("RadComboBoxClientName"), RadComboBox) combo.DataSource = Streams ' This is a Dictionary(Of Decimal, String) combo.DataValueField = "value" combo.DataTextField = "value" End IfEnd SubAnd the whole grid is bound in the NeedDataSource event.
The grid is displayed correctly and the drop-down list is populated correctly, but if I select a in the drop-down list to filter by it, then the grid refreshes and all the records are "filtered" (so it doesn't matter which value I select for filtering: I will always get no results, even if the list contains valid items), so the filtered grid will always be empty (see attachments).
I've tried several approaches and followed the tutorials and demos, but I couldn't get this working.
What am I doing wrong?
Thanks in advance.