FilterDescriptors.Expression allways empty

12 posts, 0 answers
  1. Vicent
    Vicent avatar
    1 posts
    Member since:
    Mar 2015

    Posted 13 May 2016 Link to this post

    I have this piece of code very similar to the one in the demos but I allways get an empty string from FilterDescriptors.Expression

     

    this.Confecciones.AllowFiltering = true;

    this.ConfeccionesGV.FilterChanged += Confecciones_FilterChanged;

     

     

    void ConfeccionesGV_FilterChanged(object sender, VirtualGridEventArgs e)
            {
                Filter();
            }

            private void Filter()
            {
                string filterExpression = this.ConfeccionesGV.FilterDescriptors.Expression;
                if (!string.IsNullOrEmpty(filterExpression))
                    MessageBox.Show(filterExpression);
            }

  2. Dimitar
    Admin
    Dimitar avatar
    1748 posts

    Posted 17 May 2016 Link to this post

    Hello Vicent,

    Thank you for writing.

    You need to specify the FieldName in the CellValueNeeded event handler. This way the expression will be set properly:
    if (e.RowIndex < 0)
    {
        e.FieldName = "Col" + e.ColumnIndex;
    }

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. Saji
    Saji avatar
    13 posts
    Member since:
    Mar 2016

    Posted 21 Dec 2016 Link to this post

    I have the same issue. I do set the the e.FieldName and e.Value in the CellValueNeeded event. While sorting, the SortingDescriptor returns PropertyName, but when I attempt to filter, no PropertyName (PropertyName returns an empty string, while Filter text is available) in FilterDescriptor available from GRID.FilterDescriptors collection property.
  4. Dimitar
    Admin
    Dimitar avatar
    1748 posts

    Posted 22 Dec 2016 Link to this post

    Hi Saji,

    I have used the following code with the latest version and the results are correct on my side. What I need to change in order to reproduce this:
    public RadForm1()
    {
        InitializeComponent();
        radVirtualGrid1.CellValueNeeded += RadVirtualGrid1_CellValueNeeded;
        radVirtualGrid1.ColumnCount = 10;
        radVirtualGrid1.RowCount = 100;
        radVirtualGrid1.FilterChanged += RadVirtualGrid1_FilterChanged;
     
    }
     
    private void RadVirtualGrid1_FilterChanged(object sender, Telerik.WinControls.UI.VirtualGridEventArgs e)
    {
        Console.WriteLine(radVirtualGrid1.FilterDescriptors[0].Expression);
        Console.WriteLine(radVirtualGrid1.FilterDescriptors[0].PropertyName);
    }
     
    private void RadVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e)
    {
        e.Value = "test";
        e.FieldName = "Field" + e.RowIndex + " " + e.ColumnIndex;
        
    }

    I am looking forward to your reply.
     
    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Saji
    Saji avatar
    13 posts
    Member since:
    Mar 2016

    Posted 12 Jan in reply to Dimitar Link to this post

    Hi Dimitar, 

    It was my mistake. I had field name/value setting lines inside an if condition like below. Now I moved it outside the if block.

                if (e.RowIndex == RadVirtualGrid.HeaderRowIndex) // header

                {
                    e.FieldName = GetFieldName(headerItem);
                    e.Value = headerItem.DisplayName;

    Thanks,

    Saji.

  6. Dimitar
    Admin
    Dimitar avatar
    1748 posts

    Posted 13 Jan Link to this post

    Hi Saji,

    I am glad that you have found a solution for this case. Do not hesitate to contact us if you have other questions.
     
    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Padre
    Padre avatar
    7 posts
    Member since:
    Dec 2016

    Posted 25 Jan Link to this post

    Hello. 

    I need help.

    How can delete filter in standart filterdescriptions collection? 

    For example. Grid contain columns with int values, but in filters have operators like or notlike. We recieve error if use this filters

  8. Dimitar
    Admin
    Dimitar avatar
    1748 posts

    Posted 26 Jan Link to this post

    Hi Padre,

    You can use the Remove, RemoveAt or Clear methods: 
    radVirtualGrid1.FilterDescriptors.RemoveAt(0);
    radVirtualGrid1.FilterDescriptors.Clear();

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  9. Padre
    Padre avatar
    7 posts
    Member since:
    Dec 2016

    Posted 26 Jan in reply to Dimitar Link to this post

    Hi, Dimitar.

    tis functions use to clear filters, but no context menu with operation types.

    May be to use

    this.VirtualGrid.MasterViewInfo.SetColumnDataType(new Type[] {typeof(String), typeof(decimal)});

  10. Dimitar
    Admin
    Dimitar avatar
    1748 posts

    Posted 26 Jan Link to this post

    Hi Padre,

    Yes, setting the data type will give you a correct set of items in the filter drop down. You can set this using a column index as well:
    this.radVirtualGrid1.MasterViewInfo.SetColumnDataType(1, typeof(DateTime) );

    Please let me know if there is something else I can help you with. 

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  11. Padre
    Padre avatar
    7 posts
    Member since:
    Dec 2016

    Posted 26 Jan in reply to Dimitar Link to this post

    Hi, Dimitar.
    No, thanks. Thanks for help.
    Best regards.

  12. Saji
    Saji avatar
    13 posts
    Member since:
    Mar 2016

    Posted 26 Jan Link to this post

    An approach I followed is: enumerate through the grid.FilterDescriptions() and create a new collection filter descriptors with the operator you want.

     

    var newDescList = new FilterDescriptorCollection();

    foreach(var x in grid.FilterDescriptors)

    { 

    var newDesc = new CoreVirtualGridFilterDescriptor(x.PropertyName, youroperator, x.Value)    

    newDescList.Add(newDesc);

    }

    // now use newDescList for your filtering purpose.

Back to Top