Hello, I am looking for a library to build function like expressions in JavaScript. The idea is that the library shall allow me to define the user functions and the user shall be able to choose the different functions. I found 2 libraries that match partially my requirements, one of them meet my functional requirements and the other my UI design requirement. So I would like to ask you if you know any library that may fit better.

The libraries that I found are JQuery Expression Builder and JQuery Query Builder.

On one hand, the JQuery Expression Builder meets my functional requirements, as it allows to define easily the different functions and variables that the user can use. The data is defined as follows:

var options = {
  functions: {
    Add: function (x, y) {
      return x + y;
    Sub: function (x, y) {
      return x - y;
  varaibles: [
      variableId: 1,
      name: 'FirstName'
      variableId: 2,
      name: 'Age'

And then it is possible to use it as Add(Add(2,FirstName), Sub(2, Age)), which is the functionality I want, it has autocompletion but it does not have a more guided UI to select the operations to perform, just plain text validation. A live demo can be found here.

On the other I found JQuery Query Builder whose functionality focuses on building SQL queries, which is not my use case, but which has a design based on tree structured selectors that guides the user while building the query

r/webdev - Any suggestion on a Expression Builder library for JavaScipt?

JQuery Query Builder Example

The problem with this library is that it focuses on building SQL queries, then, every field shall have at least an operator, and they are joined by AND/OR logical expressions. Check a live demo here.

In this case I would expect to have SUM/DIV/SUB/SUM_IF instead of AND/OR, and to have a selector to choose between the different predefined fields, creating a tree like structure to define the struct.

Do you know any other expression builder library which can meet both requirements? To create flexible function like operations and to have a guided UI that can help the user to decide what he can do or else.

Thank you! 😀

Source link

Write A Comment