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

RadGrid filter is filtering client side as well as server side

1 Answer 159 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 13 Nov 2012, 08:47 PM
Hey,

I have a RadGrid which is filtering (using dynamic LINQ), sorting and paging server side within the NeedDataSource event and everything is working perfectly. However, one of the properties I am binding to is a lookup to another table. This is workable, so in NeedDataSource I perform my lookup and set the value e.g. Say the property is called "CategoryID". I wish to display the category name as opposed to the ID. Because of this, I have the the filter template in my grid where the user can choose from a drop down list. The query will use the value "C1" for Category1 and so on (based on different text/value attributes in the RadComboBoxItem). My query runs fine (selects from table where CategoryID = 'C1') and returns results. Unfortunately, the Grid seems to being filtering client side after the results are returned (so it eliminates results that don't equal 'C1', which is everything). I can tell it's being done client side because:

1. I can put a break point in on the server and see my results after my filtering/sorting/paging.
2. If I name the CategoryID and Caterory name the same thing, the results display as expected.
3. The Grid actually displays the number of results and the correct page numbers successfully at the bottom.

Any help is much appreciated, I'm so close!

<telerik:RadGrid ID="radGridExperienceEntry" runat="server" OnNeedDataSource="GetData">
    <GroupingSettings CaseSensitive="False" />
    <MasterTableView AutoGenerateColumns="false" DataKeyNames="Id">
        <Columns>
            <telerik:GridBoundColumn DataField="Category" UniqueName="Category" HeaderText="Category Type">
                <FilterTemplate>
                    <telerik:RadComboBox ID="RadComboBoxCategory" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Category").CurrentFilterValue %>'
                        runat="server" OnClientSelectedIndexChanged="IndexChanged">
                        <Items>
                            <telerik:RadComboBoxItem Text="All" />
                            <telerik:RadComboBoxItem Text="Category1" Value="C1" />
                            <telerik:RadComboBoxItem Text="Category2" Value="C2" />
                        </Items>
                    </telerik:RadComboBox>
                    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                        <script type="text/javascript">
                            function IndexChanged(sender, args) {
                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                tableView.filter("Category", args.get_item().get_value(), "EqualTo");
                            }
                        </script>
                    </telerik:RadScriptBlock>
                </FilterTemplate>
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 16 Nov 2012, 12:30 PM
Hi David,

Based on your description it is hard to determine the problem. The issue could be caused from the DataSource. Are you sure the Category and CategoryID exists in the RadGrid data source? The RadGrid could not filter data client-side so the source of the issue should be somewhere else.

If you issue still persists you could create a sample project showing the unwanted behavior and remotely host it so we could be able to download it, debug it and advise you with the best possible solution.

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or