This is a migrated thread and some comments may be shown as answers.

Problem with filtering and GroupByExpression

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ferdinand
Top achievements
Rank 1
Ferdinand asked on 22 Feb 2011, 10:18 AM
Hi there.
I have the following grid:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="true"
    GridLines="None" Width="100%" DataSourceID="ObjectDataSource1" meta:resourcekey="RadGrid1Resource1"
    OnItemDataBound="RadGrid1_ItemDataBound">
    <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
    <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" />
    <MasterTableView AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
        <Columns>
            <telerik:GridTemplateColumn meta:resourcekey="GridTemplateColumnResource1" UniqueName="TemplateColumn" AllowFiltering="false">
                <ItemTemplate>
                    <a href="Rightdata.aspx" onclick='openDataWindow('RightData.aspx?id=<%# Eval("ID") %>', 'RadWindow1'); return false;'>
                        <img alt="bearbeiten" style="border: 0;" src="img/scroll2_edit_24.png" title="bearbeiten" />
                    </a>
                    <asp:ImageButton ID="ImageButton2" runat="server" CommandArgument='<%# Eval("ID") %>'
                        CommandName="Delete" ImageUrl="img/scroll2_delete_24.png" meta:resourcekey="ImageButton2Resource1"
                        OnClick="ImageButton2_Click" />
                </ItemTemplate>
                <ItemStyle CssClass="style1" />
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="Name" HeaderText="Anzeigename" meta:resourcekey="GridBoundColumnResource1"
                SortExpression="Name" UniqueName="Name">
                <ItemStyle CssClass="style2" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="UniqueName" HeaderText="UniqueName" meta:resourcekey="GridBoundColumnResource2"
                SortExpression="UniqueName" UniqueName="UniqueName">
                <ItemStyle CssClass="style2" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Description" HeaderText="Beschreibung" meta:resourcekey="GridBoundColumnResource3"
                SortExpression="Description" UniqueName="Description">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowSorting="False" DataField="ParentCategory" HeaderText="überg. Kategorie"
                meta:resourcekey="GridBoundColumnResource4" UniqueName="Category">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowSorting="False" DataField="Category" HeaderText="Kategorie"
                meta:resourcekey="GridBoundColumnResource5" UniqueName="Category">
            </telerik:GridBoundColumn>
        </Columns>
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldAlias="Kategorie" FieldName="ParentCategory" FormatString=""
                        HeaderText="" meta:resourcekey="GridGroupByFieldResource1" />
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldAlias="ParentCategory" FieldName="ParentCategory"
                        meta:resourcekey="GridGroupByFieldResource2" />
                </GroupByFields>
            </telerik:GridGroupByExpression>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldAlias="Unterkategorie" FieldName="Category" FormatString=""
                        HeaderText="" meta:resourcekey="GridGroupByFieldResource3" />
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldAlias="Category" FieldName="Category" meta:resourcekey="GridGroupByFieldResource4" />
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
    </MasterTableView>
</telerik:RadGrid>

If I turn on the AllowFilteringByColumn property the following error occurs:
Multiple controls with the ID FilterTyexBox_Category found. FindControl requires that controls have unique IDs.

What did I miss?

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 25 Feb 2011, 08:24 AM
Hello Ferdinand,

As the exception states, your grid contains two columns with the same UniqueName set. Here is a small excerpt from your code:

<telerik:GridBoundColumn AllowSorting="False" DataField="ParentCategory" HeaderText="überg. Kategorie"
    meta:resourcekey="GridBoundColumnResource4" UniqueName="Category">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowSorting="False" DataField="Category" HeaderText="Kategorie"
    meta:resourcekey="GridBoundColumnResource5" UniqueName="Category">

Please change one of the highlighted unique names above and verify whether the problem still exists.

I hope this helps.

Greetings,
Martin
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Ferdinand
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or