devexpress-filter-converter

1.4.0 • Public • Published

DevExpress boolean filter express tree converter

npm version

Implementing server side operations with DevExpress DataGrid (or to be more specific DataStore) is required when dealing with large data sets.

DevExpress supports OData store by default.

But if you want to write your own custom store, parsing the filter expression generated by DevExpress is not an easy task, since the filter data structure is not static, and can have multiple structures, dealing with it on strongly typed language like Java or C# can be cumbersome.

This tiny library transform the filter tree to a more structural format, that can be parsed easily in a server side language.

It have no dependencies at all, just some lines of JavaScript code.

Some examples

from

[
    "name", "=", "hello"
]

to

{
 "left": "name",
 "op": "=",
 "right": "hello"
}

from

[
    ["name", "=", "hello"],
    "and",
    ["last_name", "=", "value"],
]

to

{
 "booleanOperator": "and",
 "conditions": [
  {
   "left": "name",
   "op": "=",
   "right": "hello"
  },
  {
   "left": "last_name",
   "op": "=",
   "right": "value"
  }
 ]
}

from

[
    ["name", "=", "hello"],
    "and",
    ["last_name", "=", "value"],
    "or",
    ["age", ">", 20],
]

to

{
 "booleanOperator": "or",
 "conditions": [
  {
   "booleanOperator": "and",
   "conditions": [
    {
     "left": "name",
     "op": "=",
     "right": "hello"
    },
    {
     "left": "last_name",
     "op": "=",
     "right": "value"
    }
   ]
  },
  {
   "left": "age",
   "op": ">",
   "right": 20
  }
 ]
}

Package Sidebar

Install

npm i devexpress-filter-converter

Weekly Downloads

2

Version

1.4.0

License

MIT

Unpacked Size

14.3 kB

Total Files

11

Last publish

Collaborators

  • ahmadmoussawi