VirtualGrid default filter descriptor

1 Answer 54 Views
VirtualGrid
Emanuele
Top achievements
Rank 1
Iron
Iron
Emanuele asked on 19 Nov 2024, 11:17 AM

Hi,

in VirtualGrid, is there a way to set the default filter descriptor (different from "contains")?

Something like you suggest for the Grid control (https://www.telerik.com/forums/how-to-set-default-of-filterdescriptor-operator).

Thank you,

 

Emanuele

1 Answer, 1 is accepted

Sort by
1
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 19 Nov 2024, 02:57 PM

Hello, Emanuele,

In order to change the default filter operator for a particular column in RadVirtualGrid, you can use a custom VirtualGridFilterCellElement. Please refer to the following article for more information: Creating custom cells - RadVirtualGrid - Telerik UI for WinForms

I created a sample code example for changing the filter operator to a string column. Feel free to use this as an example and achieve your goal:

private void RadVirtualGrid1_CreateCellElement(object sender, VirtualGridCreateCellEventArgs e)
{
    if (e.CellType == typeof(VirtualGridFilterCellElement))
    {
        e.CellElement = new CustomVirtualGridFilterCellElement();
    }
}

public class CustomVirtualGridFilterCellElement : VirtualGridFilterCellElement
{
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(VirtualGridFilterCellElement);
        }
    }
    protected override void UpdateInfo(VirtualGridCellValueNeededEventArgs args)
    {
        base.UpdateInfo(args);
        if (this.Descriptor == null)
        {
            Type columnType = this.ViewInfo.GetColumnDataType(this.ColumnIndex);
            if (this.ColumnIndex == 0)
            {
                RadVirtualGridLocalizationProvider currentProvider = RadVirtualGridLocalizationProvider.CurrentProvider;
                string text = currentProvider.GetLocalizedString(RadVirtualGridStringId.FilterFunctionDoesNotContain);
                this.FilterOperatorText.Text = text + ":";
            }
        }
    }
}

I hope this helps. If you have any other questions do not hesitate to contact me. 

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Emanuele
Top achievements
Rank 1
Iron
Iron
commented on 19 Nov 2024, 03:31 PM

Thank you, it works!

Emanuele

Tags
VirtualGrid
Asked by
Emanuele
Top achievements
Rank 1
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or