filter by DataKeys or DataItem's text?

4 posts, 0 answers
  1. Jayd
    Jayd avatar
    9 posts
    Member since:
    Mar 2011

    Posted 27 Jun 2011 Link to this post

    I am using a RadFilter with a RadGrid.  So far I have only got the RadFilter to work when my FilterExpression's FieldName is equal to a GridBoundColumn's DataField.

    I have a column where the text displayed to the user is a concatenation of 3 fields from my DataSource.  However, I want the user to be able to filter by each of these fields individually.  Adding the individual fields as DataKeys did not work.  Right now I have it working by having 3 GridBoundColumns with DataField set to each of the 3 individual fields, and Visible=false.  Are there any performance implications to this approach?  Even if there aren't any, I still think it's messy code.  I would prefer to use the DataKey if possible.

    I have another column where the value from my DataSource is an int.  However, to get the value I display to the user, I cast this int to an enum and call ToString().  I am building my filter expressions programmatically.  Right now it seems like I would have to build a RadFilterEqualToFilterExpression<int> for this column.  However, all my other columns would use RadFilterEqualToFilterExpression<string>.  My code would be much simpler if I could use RadFilterEqualToFilterExpression<string> for all my columns.  Is it possible to filter by DataItem["uniqueName"].Text?

    Thank you!
  2. Tsvetina
    Admin
    Tsvetina avatar
    1873 posts

    Posted 30 Jun 2011 Link to this post

    Hi Jayd,

    It might be easier for you if instead of pointing the grid as a filtered control for the RadFilter, you could just add declarative field editors and use them to build the filterexpression. Then, in the ApplyExpressions event of the filter, create an appropriate type of query provider, build a filter expression and set it to RadGridInstance.MasterTableView.FilterExpression. Finally, rebind the grid:
    protected void RadFilter1_ApplyExpressions(object sender, RadFilterApplyExpressionsEventArgs e)
    {
        RadFilterSqlQueryProvider provider = new RadFilterSqlQueryProvider();
        provider.ProcessGroup(e.ExpressionRoot);
        grdRequest.MasterTableView.FilterExpression = provider.Result;
        grdRequest.Rebind();
    }


    Kind regards,
    Tsvetina
    the Telerik team

    Browse the vast support resources we have to jump start 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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jayd
    Jayd avatar
    9 posts
    Member since:
    Mar 2011

    Posted 07 Jul 2011 Link to this post

    I don't see how this would allow me to filter by the DataItem's text.
  5. Tsvetina
    Admin
    Tsvetina avatar
    1873 posts

    Posted 13 Jul 2011 Link to this post

    Hello Jayd,

    If the text contains two fields, as it indeed seems so from your initial post, this approach might not help. Excuse me for missing that part.
    As for using a string filter expression instead of int, I assume it might not work, since it will not match the syntax expected by the datasource that you use. You can see for yourself how the expressions will differ if you use string instead of int type of expression here:
    http://www.telerik.com/help/aspnet-ajax/grid-operate-with-filter-expression-manually.html (the table at the bottom)
    Generally, you can build expressions that match the fields in the datasource. If you create an additional string field containing the two pieces of data, you will be able to filter by it. If you have two separate fields, you will need to build an expression for each of them separately and add them to the same group.

    All the best,
    Tsvetina
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top