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

How do I stop the client side filtering?

5 Answers 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
troyboy
Top achievements
Rank 1
troyboy asked on 15 Nov 2010, 01:54 AM

Hi, I am getting a double filtering effect happening. Once on the server side and then one more time on the client side. This double filtering wouldn't be an issue except for one of my columns (Description) is 2000 characters long so I only pass back the first 200 characters. If the data I filtered on is after the first 200 characters then the client side filter removes the row.
 
I do server side filtering by using the datasource selecting event:

protected void objItems_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
    e.InputParameters["sortExpression"] = RadGrid1.MasterTableView.SortExpressions.GetSortString();
    e.InputParameters["filterExpression"] = RadGrid1.MasterTableView.FilterExpression;
    if (e.ExecutingSelectCount)
    {
        // count is done last
        //RadGrid1.MasterTableView.FilterExpression = "";
        // while using the above line worked it failed when going from page to page
    }
    else
    {
        // selection is done first
    }
}

 

 

public IList get(int catalogueId, string sortExpression, string filterExpression, int maximumRows, int startRowIndex)

 

{
...

}

5 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 18 Nov 2010, 10:24 AM
Hello,

What do you mean by saying that the RadGrid is filtered client-side? If it is bound to a datasource control, it filters only server-side.

Are you sure that you cancel out the default grid filtering when filtering the datasource in its selecting event handler? You should make sure that the FilterExpression string is cleared in order to prevent the grid from executing its own filtering on the set of data which is passed to it.

All the best,
Tsvetina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
troyboy
Top achievements
Rank 1
answered on 19 Nov 2010, 01:10 AM

If you look at my code example in the original post, you will see that I have commented out the filter expression clear.

//RadGrid1.MasterTableView.FilterExpression = "";

If I uncomment that line then it works as you say however when I go from one grid page to another or change the grid page size I get the full contents without filtering. By leaving the line commented I get the proper filtering but it's done twice.

Here is my radgrid in case you are interested:

<telerik:RadGrid ID="RadGrid1" runat="server"
    DataSourceID="objItems"
    GridLines="None"
    AllowFilteringByColumn="True"
    AllowPaging="True"
    AllowSorting="True"
    EnableLinqExpressions="true"
    OnInit="RadGrid1_Init"
    OnItemCreated="RadGrid1_ItemCreated" PagerStyle-AlwaysVisible="true" PagerStyle-Position="TopAndBottom">
    <MasterTableView
        AutoGenerateColumns="False"
        DataSourceID="objItems"
        DataKeyNames="CatalogueItemId"
        EditMode="PopUp"
        OverrideDataSourceControlSorting="true" ItemStyle-VerticalAlign="Top">
          
        <RowIndicatorColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"  ItemStyle-VerticalAlign="Top"></telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="StockNumber" HeaderText="Stock Number" SortExpression="StockNumber"
                UniqueName="StockNumber" ItemStyle-VerticalAlign="Top">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product Name" SortExpression="ProductName"
                UniqueName="ProductName" ItemStyle-VerticalAlign="Top" ItemStyle-Height="50px">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn UniqueName="Description2"  ItemStyle-VerticalAlign="Top" DataField="Description" SortExpression="Description" HeaderText="Description">
                <ItemTemplate>
                    <div style="height: 60px; overflow: hidden">
                        <asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                    </div>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="PartNumber" HeaderText="Part Number" SortExpression="PartNumber"
                UniqueName="PartNumber" ItemStyle-VerticalAlign="Top">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ISBN13" HeaderText="ISBN13" SortExpression="ISBN13"
                UniqueName="ISBN13" ItemStyle-VerticalAlign="Top">
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn ConfirmText="Delete this item?" ConfirmDialogType="RadWindow"
                ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                UniqueName="DeleteColumn" ItemStyle-VerticalAlign="Top">
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
0
Tsvetina
Telerik team
answered on 24 Nov 2010, 11:25 AM
Hello,

In case you do not want to use the built-in filter expression, you should clear it on ItemCommand of the grid (when the command name is GridFilterCommandName) and then assign a filtered datasource to RadGrid in its NeedDataSource event handler.

Greetings,
Tsvetina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
troyboy
Top achievements
Rank 1
answered on 25 Nov 2010, 06:47 AM
Not sure what you mean. I already have a filtered datasource. As far as on itemcommand, this is what I have so far:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "Filter")
    {
        if (e.Item is GridFilteringItem)
        {
            GridFilteringItem item = (GridFilteringItem)e.Item;
        }
    }
}

but I don't know how to clear it?
0
Tsvetina
Telerik team
answered on 29 Nov 2010, 09:49 AM
Hi,

You can take a look at this help article (Example 2) in order to see how to access and change the filter expression in ItemCommand event handler of RadGrid.

All the best,
Tsvetina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
troyboy
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
troyboy
Top achievements
Rank 1
Share this question
or