I am trying to determine how to programmatically add a clause to a FilterBuilder, i.e. click a button and a new clause gets added to a FilterBuilder. I am assuming that FilterBuilder.addClause(FilterClause) would do the trick, but I cannot make sense out of how to construct a FilterClause such that this does what I want. I have been searching through the forums, showcase code, etc. and can't find an example that constructs a FilterClause or uses FilterBuilder.addClause. Is there an example anywhere that shows the construction of a FilterClause and invocation of FilterBuilder.addClause such that the result is the same as if the user had clicked on the + sign and added a new clause?
As some background, I am trying to use FilterBuilder as a means to construct a nested boolean expression that is specific to my application and not equivalent to a database table query/filter condition. What I would like to be able to do is provide a list of values to pick from (equivalent to the "Country", "Government", "G8", etc. fields in the FilterBuilder showcase example), then simple choices of "Equals" or "Not Equal", and either "True" or "False". I would like the default of each to be "Equals" and "True".
The list of items to filter on may be several hundred items long. As such, I would like to construct a separate tree, and allow for a doubleClick on a tree node (or perhaps a drag from the tree to the FilterBuilder) to add the selected item to the FilterBuilder programmatically.
Is this possible, and is addClause the way to do it?
Additional questions:
1) It appears you cannot just pass a list of values to pick from in FilterBuilder. My data (the values I want to pick from to construct a filter clause) are in rows in a database table, _not_ the columns of the table. It seems that the designers of FilterBuilder did not consider this case. To work around this, I am constructing a DataSource dynamically that translates each row to a DataSourceField. Is there a better way?
2) You can limit the available operators via setValidOperators(OperatorId.EQUALS, OperatorId.NOT_EQUAL) and limit the allowable values using setValueMap("True", "False");. But is there a way to force the default value of a new filter clause to be "True" instead of blank?
3) Is there a way to configure FilterBuilder so that instead of presenting my list of several hundred values as a simple drop down list, it could be a Picktree or other structure that would be simpler to navigate?
Thank you very much.
As some background, I am trying to use FilterBuilder as a means to construct a nested boolean expression that is specific to my application and not equivalent to a database table query/filter condition. What I would like to be able to do is provide a list of values to pick from (equivalent to the "Country", "Government", "G8", etc. fields in the FilterBuilder showcase example), then simple choices of "Equals" or "Not Equal", and either "True" or "False". I would like the default of each to be "Equals" and "True".
The list of items to filter on may be several hundred items long. As such, I would like to construct a separate tree, and allow for a doubleClick on a tree node (or perhaps a drag from the tree to the FilterBuilder) to add the selected item to the FilterBuilder programmatically.
Is this possible, and is addClause the way to do it?
Additional questions:
1) It appears you cannot just pass a list of values to pick from in FilterBuilder. My data (the values I want to pick from to construct a filter clause) are in rows in a database table, _not_ the columns of the table. It seems that the designers of FilterBuilder did not consider this case. To work around this, I am constructing a DataSource dynamically that translates each row to a DataSourceField. Is there a better way?
2) You can limit the available operators via setValidOperators(OperatorId.EQUALS, OperatorId.NOT_EQUAL) and limit the allowable values using setValueMap("True", "False");. But is there a way to force the default value of a new filter clause to be "True" instead of blank?
3) Is there a way to configure FilterBuilder so that instead of presenting my list of several hundred values as a simple drop down list, it could be a Picktree or other structure that would be simpler to navigate?
Thank you very much.
Comment