search with more than one parameter

i wanna search datagrid with more than one parameter at the same time. what i want to achieve is i wanna use radio button to pick paid invoice and unpaid invoice, then when i choose unpaid invoice i can then type the company name on an input box.

So my datagrid will only contain Unpaid Invoice from Company A only. 
 *this is my method for searching supplier name
    public void OnInput(InputEventArgs args)
    {
        this.DefaultGrid.SearchSettings.Fields = new string[] { "Nama_Supplier" };
        this.DefaultGrid.Search(args.Value);
    }

*and this is my method when radio button clicked, it will only shown paid or unpaid invoice 
    public void DariRadioButton(string pilihan)
    {
        this.DefaultGrid.SearchSettings.Fields = new string[] { "Status_Pembayaran" };
        if (pilihan == "Lunas")
        {
            this.DefaultGrid.Search("Lunas");
        }
        else
        {
            this.DefaultGrid.Search("Dibayarkan");
        }
    }

i want to make those two search parameter co exist.

Can you help me?

1 Reply 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team March 11, 2021 01:22 PM UTC

Hi Indra, 

Greetings from Syncfusion support. 

Based on this scenario, we suggest you to use the Query property of Grid instead of using Search. With this you can generate your own query based on your requirement and apply to Grid to display the Grid data. We have prepared a sample based on this scenario using Query property, please download the sample from the link below, 
References :  
 
We suggest you to generate the query based on your scenario and update the Grid data. Please refer the codes below, 

 
    <SfGrid @ref="DefaultGrid" DataSource="@Orders" Query="@SearchQuery"> 

    public Query SearchQuery { getset; }    ...    WhereFilter ColPre = new WhereFilter();    List<WhereFilter> Predicate = new List<WhereFilter>();    public void OnInput(InputEventArgs args)    {        Predicate = new List<WhereFilter>();        Predicate.Add(new WhereFilter()        {            Field = "CustomerID",            value = args.Value,            Operator = "contains",            IgnoreCase = true        });        ColPre = WhereFilter.Or(Predicate);        SearchQuery = new Query().Where(ColPre);    }     public void DariRadioButton(ChangeArgs<bool> pilihan)    {        Predicate.Add(new WhereFilter()        {            Field = "Paid",            value = "Lunas",            Operator = "equal",            IgnoreCase = true        });         ColPre = WhereFilter.And(Predicate);        SearchQuery = new Query().Where(ColPre);    }

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer
Loader.
Up arrow icon