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

FilterDescriptors.Expression allways empty

13 Answers 182 Views
VirtualGrid
This is a migrated thread and some comments may be shown as answers.
Vicent
Top achievements
Rank 1
Vicent asked on 13 May 2016, 04:12 PM

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);
        }

13 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 17 May 2016, 07:21 AM
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.
0
Saji
Top achievements
Rank 1
answered on 21 Dec 2016, 05:25 PM
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.
0
Dimitar
Telerik team
answered on 22 Dec 2016, 09:44 AM
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.
0
Saji
Top achievements
Rank 1
answered on 12 Jan 2017, 04:05 PM

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.

0
Dimitar
Telerik team
answered on 13 Jan 2017, 08:41 AM
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.
0
Padre
Top achievements
Rank 1
answered on 25 Jan 2017, 02:34 PM

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

0
Dimitar
Telerik team
answered on 26 Jan 2017, 08:00 AM
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.
0
Padre
Top achievements
Rank 1
answered on 26 Jan 2017, 08:36 AM

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)});

0
Dimitar
Telerik team
answered on 26 Jan 2017, 01:42 PM
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.
0
Padre
Top achievements
Rank 1
answered on 26 Jan 2017, 02:13 PM

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

0
Saji
Top achievements
Rank 1
answered on 26 Jan 2017, 02:20 PM
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.

0
Aseman
Top achievements
Rank 1
Veteran
answered on 04 Jan 2020, 05:35 PM

Hello Dimitar 

Excuse me Can you explain me all the conditions in Cellvalur Needed Event ? like "if (e.RowIndex < 0) " or  " if (e.RowIndex == RadVirtualGrid.HeaderRowIndex)"

thanks

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Jan 2020, 07:32 AM
Hello, Aseman,   

The CellValueNeeded event in RadVirtualGrid is fired whenever a cell value is required by the grid. It is necessary to specify the Value argument considering the RowIndex/ColumnIndex. Additional information how to populate RadVirtualGrid with data is available here: https://docs.telerik.com/devtools/winforms/controls/virtualgrid/working-with-data/virtualgrid-populating-with-data 

All data rows have index greater than or equal to 0. The system rows have index less than 0. The following help article illustrates the available system rows in RadVirtualGrid: https://docs.telerik.com/devtools/winforms/controls/virtualgrid/rows/system-rows 
Here are the respective index of the row:
- HeaderRowIndex = -1
- NewRowIndex = -2
- FilterRowIndex = -3

I hope this information helps. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
VirtualGrid
Asked by
Vicent
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Saji
Top achievements
Rank 1
Padre
Top achievements
Rank 1
Aseman
Top achievements
Rank 1
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or