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

DataOperations PerformWhereFilter Not Working

Version 15.2.0.40

I've got a class that performs the server side data operations for me. Sorting and paging work fine, but the filter keeps returning the same data. I've confirmed that the where filter being passed in is correct.

I've attached some text files with code snippets demonstrating what I'm trying to do and a comment in the "sample-grid-data-operations-class.txt" where I'm trying to apply the WHERE filter. I've used this same method to perform searches with your ejAutocomplete control.

Any ideas as to why this is not working? 

Attachment: samplegrid_4e4250e3.zip

7 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team June 29, 2017 05:24 PM UTC

Hi Matt, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we are able to reproduce the reported issue from our end. In the given code snippets you have using the where condition as “PerformWhereFilter(data, dm.Where, whereCondition)” whereCondition is assigned by you but in default the operators where passed in the where filter arguments. So, you no need to pass a variable in performWhereFIlter() method. 

Use the below code example for operator specifying in adaptor. 


public ActionResult DataSource(DataManager dm) 
        { 
            BindDataSource(); 
            IEnumerable DataSource = order.ToList(); 
            DataResult result = new DataResult(); 
            DataOperations operation = new DataOperations(); 
            result.result = DataSource; 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
            { 
                result.result = operation.PerformSorting(result.result, dm.Sorted); 
            } 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                result.result = operation.PerformWhereFilter(DataSource, dm.Where, dm.Where[0].Operator); 
            } 
            result.count = result.result.AsQueryable().Count(); 
            if (dm.Skip > 0) 
                result.result = operation.PerformSkip(result.result, dm.Skip); 
            if (dm.Take > 0) 
                result.result = operation.PerformTake(result.result, dm.Take); 
 
            return Json(new { result = result.result, count = result.count }, JsonRequestBehavior.AllowGet); 
        } 


We have prepared a sample and it can be downloadable from the below location. 


For more information you can refer the following Knowledge Base link 
 

If we misunderstood your query then please get back to us. 

Regards, 
Thavasianand S. 



MA Matt Abercrombie June 29, 2017 05:48 PM UTC

Ugh. I'm kicking myself over that one. Your solution works perfectly. Thank you again for the wonderful support.



TS Thavasianand Sankaranarayanan Syncfusion Team June 30, 2017 04:12 AM UTC

Hi Matt, 

We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
 
Regards, 
Thavasianand S. 



BF Bruno Figueiredo November 9, 2017 05:58 PM UTC

Hi,

I have my filtering working nice.

But my client has a refined taste for requesting complex things.

So I have this code working fine:

    if (dm.Where != null && dm.Where.Count > 0) //Filtering 

            {

                dm.Where.ForEach(f => f.Operator = "contains");

                result.result = operation.PerformWhereFilter(result.result, dm.Where, "contains");// dm.Where[0].Operator);

                result.count = result.result.Cast<QuoteLineMaterial>().Count();

            }


But the client want to be able to filter by multiple words, like

they filter brands by "brand1+brand2" and the grid show the results for brand1 OR brand2

Can you help me with this request?



TS Thavasianand Sankaranarayanan Syncfusion Team November 10, 2017 12:44 PM UTC

Hi Bruno, 
 
We have analyzed your query and we suspect that you want to do filtering with multiple values. So, we suggest you to use the custom filtering in excel filter of ejGrid control. 
 
Refer the below screen shot. 
 
 
 
We have prepared a sample and it can be downloadable from the below location. 
 
 
Refer the help documentation. 
 
 
If we misunderstood your query then please get back to us with the following details for better assistance. 
 
  1. Share screen shot or video demonstration of your requirement.
  2. Share your requirement on Grid filtering with some more details.
  3. Which type of filtering that you have used in Grid.
  4. Share full Grid code example both server and client end.
  5. If possible share the sample or reproduce the issue in the attached sample.
  6. Essential Studio version details.
 
Regards, 
Thavasianand S. 



BF Bruno Figueiredo November 10, 2017 03:53 PM UTC

Thank you for your reply,

Probably I was not clear enought in my question and I am sorry for that.

The question is, in the filterbar of the grid, the customer wants to write "car+blue" and the grid automaticly filter that column to values wich have both words, like "Blue Car of Brand Y".

Meanwhile I grabed my big hammer and came out with this amazing solution :) 

And It actualy works! 

if (dm.Where != null && dm.Where.Count > 0) //Filtering 

            {

                dm.Where.ForEach(f => f.Operator = "contains");

                List<WhereFilter> filters = new List<WhereFilter>();

                for (int i = 0; i < dm.Where.Count; i++)

                {

                    if(dm.Where[i].value!=null && dm.Where[i].value.ToString().Contains("+"))

                    {

                        var items = dm.Where[i].value.ToString().Split('+');

                        foreach (var item in items) {

                            filters.Add(new WhereFilter() {

                                Condition = dm.Where[i].Condition,

                                Field = dm.Where[i].Field,

                                IgnoreCase = dm.Where[i].IgnoreCase,

                                IsComplex = dm.Where[i].IsComplex,

                                Operator = dm.Where[i].Operator,

                                predicates = dm.Where[i].predicates,

                                value = item

                            });

                        }

                    }

                    else

                    {

                        filters.Add(dm.Where[i]);

                    }

                }

                dm.Where = filters;

                result.result = operation.PerformWhereFilter(result.result, dm.Where, "contains");

                result.count = result.result.Cast<QuoteLineMaterial>().Count();

            }



PK Prasanna Kumar Viswanathan Syncfusion Team November 13, 2017 12:56 PM UTC

Hi Bruno, 

Thanks for the update. 

To achieve your requirement, use filterBarTemplate feature of ejGrid. In filterBarTemplate we have three functions,  
 
Create – It is used to create the control at time of initialize. 
 
read  - It is used to read the Filter value selected. 
 
write – It is used to render the control and assign the value selected for filtering. 
 
In read function we can get the filter value in the arguments and using the value we can separate into two & passed it to the filterColumn method. For more knowledge, refer the below online sample link.  
 
 
If the mentioned solution is not satisfied then you can use own solution in your application.  
 
Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon