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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ejDataManager + ejQuery vs. ejGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

131152 Jun 23,2017 07:38 PM UTC Jun 26,2017 10:34 AM UTC JavaScript 1
loading
Tags: ejDataManager
Bobby Miller
Asked On June 23, 2017 07:38 PM UTC

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.

Karthikeyan Viswanathan [Syncfusion]
Replied On 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.  
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;