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

ejDataManager + ejQuery vs. ejGrid

How can I get an ej.Query to act like ej.Grid's filteredColumns property?

ejGrid.filterSettings.filterColumns takes an array of filter objects, which has a "predicate" field allowing the choice between "and" or "or" clauses combining the various filters.  ejQuery only has a "where" method, which does not accept parameter objects, but accepts arguments shaped like a filter except for the "predicate" field.
Is there a way to chain ejQuery where methods such that they use an "or" predicate rather than an "and" predicate?
Is there ejQuery.where or filterColumn.operator support for the SQL "IN" operator?

How to I get ejQuery to submit something that tells the ASP.NET MVC DataManager to combine clauses with OR rather than AND?

Example:  $("#grid").ejGrid({ dataSource: new ej.DataManager({ adaptor: new ej.UrlAdaptor(), url: ... }), ... });
later ...
var filters = [{field: "field", operator: "equal", value: "something", predicate: "or"}, {{field: "field", operator: "equal", value: "else", predicate: "or"}];
var grid = $("#grid").ejGrid("instance");
grid.model.filterSettings.filteredColumns = filters;
grid.refreshContents()
 ---> [SELECT ... FROM ... WHERE field = 'something' OR field = 'else']

If I try:
var dm = new ej.DataManager({ adaptor: new ej.UrlAdaptor(), url: ...});
var q = new ej.Query().where("field", "equal", "something").where("field", "equal", "else");
q.execute(dm).then(function (r) { console.log(r);});

---> [SELECT ... FROM ... WHERE field = 'something' AND field = 'else']

How can I get the queries to be the same using ej.Query?

Thanks in advance.

1 Reply

KV Karthikeyan Viswanathan Syncfusion Team June 26, 2017 10:34 AM UTC

Hi Miller,    
  
Thanks for contacting Syncfusion support. 
 
Query: Is there a way to chain ejQuery where methods such that they use an "or" predicate rather than an "and" predicate? 
 Yes, You can chain the where method using ej.Predicate for and & or operation. 
 Please refer to the help documentation link:  
                                                                                                                                                                                    
Query: Is there ejQuery.where or filterColumn.operator support for the SQL "IN" operator? 
Datamanager doesn’t have an IN operator. But ,you can use or predicate and equal filter type. 
 
Query: How to I get ejQuery to submit something that tells the ASP.NET MVC DataManager to combine clauses with OR rather than AND? 
You can execute the query using executeQuery and get the relevant data from done callback function. 
<code> 
<script type="text/javascript"> 
$(function () { 
var dataManager = ej.DataManager({ url: "http://mvc.syncfusion.com/Services/Northwnd.svc/" }); 
var query = ej.Query() .from("Orders") .select("OrderID", "CustomerID", " EmployeeID", "Freight", "ShipCountry") .where(ej.Predicate("OrderID", ej.FilterOperators.greaterThan, 10399, true).and("CustomerID", ej.FilterOperators.startsWith, "V", true)); 
var execute = dataManager.executeQuery(query).done(function (e) { 
// do something
}); 
}); 
</script> </code>
 
 
Regards,    
Karthikeyan V.  
 


Loader.
Live Chat Icon For mobile
Up arrow icon