FilterDescriptors.Expression allways empty

6 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
    1475 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
    12 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
    1475 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
    12 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
    1475 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.
Back to Top