We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Implementing custom filter in GridMultiColumnDropDownList

Hello,

In SfMultiColumnDropDownControl, we can override bool FilterRecord(object) method in an inherited class to implement custom search feature. How can we implement the same in GridMultiColumnDropDownList?

PS: I tried using SfMultiColumnDropDownControl in GridTemplateColumn but it causes a lot of issues, including and not limited to enter key not selecting the current item.

Please help.

Regards,
Yogesh

3 Replies

JN Jayaleshwari N Syncfusion Team February 11, 2019 11:09 AM UTC

Hi Yogesh, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked the reported query “Implementing custom filter in GridMultiColumnDropDownList” from our side. You can achieve your requirement as like we override FilterRecord for SfMultiColumnDropDownControl using CustomRenderer in GridMultiColumnDropDownList. 
 
You can refer the following user guide documentation to know about custom renderer support. 
 
Code snippet C# : Custom filter for custom multicolumn drop down control. 
 
public class CustomMultiColumnControl : SfMultiColumnDropDownControl 
{ 
    protected override bool FilterRecord(object item) 
    { 
        var _item = item as SalesByYear; 
        var result = (_item.Name.Contains(this.SearchText)); 
        return result; 
    } 
} 
 
Code snippet C#:  customized drop down control used instead of default one. 
 
public class GridCellMultiColumnDropDownRendererExt : GridCellMultiColumnDropDownRenderer 
{ 
    public GridCellMultiColumnDropDownRendererExt() 
    { 
 
    } 
 
    protected override SfMultiColumnDropDownControl OnCreateEditUIElement() 
    { 
        return new CustomMultiColumnControl(); 
    } 
} 
                                                                               
Code snippet C#: Customized renderer used to achieve custom filter in GridMultiColumnDropDownList. 
 
public class SfDataGridBehavior : Behavior  <SfDataGrid> 
{ 
    protected override void OnAttached() 
    { 
        base.OnAttached(); 
        this.AssociatedObject.CellRenderers.Remove("MultiColumnDropDown"); 
        this.AssociatedObject.CellRenderers.Add("MultiColumnDropDown", new GridCellMultiColumnDropDownRendererExt()); 
    } 
} 
 
We have attached the modified sample for your reference and you can download the same from the following location. 
 
Please let us know if you would require further assistance. 
 
Regards, 
Jayaleshwari N. 



YO Yogesh February 11, 2019 12:10 PM UTC

Thanks. Actually, I was trying that already, but like this:

public class GridCellMultiColumnDropDownRendererExt : GridCellMultiColumnDropDownRenderer
{
protected override SfMultiColumnDropDownControl OnCreateEditUIElement()
{
var customMultiColumnControl = new CustomMultiColumnControl { AllowImmediatePopup = true };
customMultiColumnControl.GotKeyboardFocus += (sender, args) => { customMultiColumnControl.IsDropDownOpen = true; };

return customMultiColumnControl;
}
}

I don't know why, but it is causing strange issues. When I click on the any column in the list, it just sort of 'hangs' for lack of a better word. For about two-three seconds, the whole grid is unresponsive, and then edit mode is on, but without the dropdown popup open. 

I tried the following link too, but it caused the same issue as well:
https://www.syncfusion.com/kb/5305/how-to-open-dropdown-popup-of-the-gridmulticolumndropdownlist-while-entering-the-text

I changed the above to the following as stated in your code and the issue disappears:
protected override SfMultiColumnDropDownControl OnCreateEditUIElement() { return new CustomMultiColumnControl { AllowImmediatePopup = true }; } 

So somehow it is a bug associated with opening the dropdown programmatically. I am dropping the idea to implement auto dropdown as soon as editing starts for the time being.

Regards,
Yogesh


JN Jayaleshwari N Syncfusion Team February 12, 2019 06:17 AM UTC

Hi Yogesh, 
 
Thanks for the update. 
 
We have checked the provided code snippet in our sample (16.4.0.52) and its working fine. The dropdown opened without any issues as soon as the we goes to edit mode and then click on any column not hangs. 
 
Can you please share video or gif image which illustrate the reported issue. And also share any other property settings that you have configured in the GridMultiColumnDropDownList definition in XAML. 
 
Regards, 
Jayaleshwari N. 


Loader.
Live Chat Icon For mobile
Up arrow icon