Is it possible to extend the DataUtil class at runtime? Looking at something in the DataUtil.OperatorSymbols function and then the subsequent mapping functions for EJ2 ECMA 5. Specifically, I want to pass the following to the server so I can work with multiple values. With the below, how can I get EJ2 to not throw an error for the operator being "in", i.e. how can I create custom operators that get passed straight through to the server?
Its pretty much what I said - I need to add a new supported operator (in) which currently is not supported so how can I override the default function at runtime to support it. Here is the code as requested:
Thank you. I will be looking forward to your response and possible solution.
|
var chartQuery = new ej.data.Query().addParams("filter", { field: "CustomerID", operator: "in", value: [1, 2, 3] });
|
Thank you. That's what we did. It would be really nice if there was a way to just override / super the class, but I guess that's not possible with the integration / imports setup the way they currently are. The reason why this would be beneficial, is we have a class on the server that processes the "where" block payload from EJ components, so we would just need to add the "in" processor and it would work across all products without requiring a separate addParams and then a watcher on server side, but it is what it is for now.
Thank you again for confirming!
|
class CustomAdaptor extends ej.data.UrlAdaptor {
processQuery(dm, query, hierarchyFilters) {
// calling base class processQuery function
var original = super.processQuery.apply(this, arguments);
var data = JSON.parse(original.data);
// change the where value here
data.where = [{
"isComplex": false,
"field": "group_id",
"operator": "in",
"value": [1, 2, 3, 4],
"ignoreCase": false
}
]
original.data = JSON.stringify(data)
return original;
}
}
var dashboard_piechart2_ds = new ej.data.DataManager({
url: "/Home/UrlDatasource",
adaptor: new CustomAdaptor()
});
|