Finally, I use the SQL parser on the client side to construct conditions tree and send to server like json.
Its my simplified administration interface:
https://gist.github.com/Somewater/5705567
in a nutshell:
1) ReQueryBulder generate SQL request (string)
2) SQL Parser create SQL request structure
3) My code convert SQL Parser structure to simple json (as stated above)
4) send json to the server
And server request parser (ruby):
https://gist.github.com/Somewater/5705620
And I can handle request on server like this (Rails request controller in my example):
include ConditionsBuilder
cond = JSON.parse(request.params['cond']) # conditions like json string
condTree = self.parse_sql_conditions_from_json(cond) # conditions like btree structure
# perform some conditions checks, for example, add additional conditions
permission_conds = And[ GtEq['permissions', 12], Eq['is_admin', 1] ]
condTree = And[condTree, permission_conds]
conditions = self.build_sql_conditions((Time.new - 90.days).to_i, Time.new.to_i, condTree)
# handle sql request: "SELECT * FROM tablename WHERE " + conditions.to_s