Take difference between two dataSources


Is there a way within the UI framework to specify on a dataSource to subtract objects that are present in a separate dataSource?

so, if I have one dataSource for KendoGrid1 designed as:

"spec": {
    "include": "...",
    "filter": "storedCalcField == true",
    "order": "..."

The user is allowed to remove items from KendoGrid1 in memory (not actually update the record, just remove it from the collection), or they can open up a modal that shows KendoGrid2, where they are allowed to add elements from this list back to KendoGrid1.

I want KendoGrid2’s dataSource to just be all the objects which are not currently in the collection for KendoGrid1. Would the best way to do this be just to add/remove those objects from those collections?


You could write a local data source that manages these interactions:

ui module XYZ {
    dataSource MyDataSource2 {
        "record": false,
        "collection": true,
        "localData": true

Then once they’ve made their selection and clicked the remove button (I imagine), this would trigger a UIAction:

type MyCustomAction mixes UIActionAction {
  dispatch: ~ js client

function dispatch(component, e) {

var env = this.get("environment"),
dataSource1 = env.getDataSource('XYZ.DataSource1'),
dataSource2 = env.getDataSource('XYZ.DataSource2')

// then something like...
dataSource2.add(dataSource1.selection, false);
dataSouce1.remove(dataSouce1.selection, false);





You could also just have a 2nd data source with the inverse filter…

"spec": {
    "include": "...",
    "filter": "storedCalcField != true",
    "order": "..."


Initially yes, but if the user were to remove some items from KendoGrid1 but wants to add it back in, they would want to see that show up in KendoGrid2. Also, if they add some items from KG2 to KG1, then open up that same modal again to add more they shouldn’t see those same items they just added to KG1


My man, appreciate it!