HomeActive Query BuilderCan I prevent a user from selecting fields in a table?

Can I prevent a user from selecting fields in a table?


Hello,

I'm using active query builder's Java version 11.3-b02. Now I'm creating queries that contain a fixed number of columns,
that begin with a predefined query: "SELECT '' AS a, '' AS b FROM my_table"
and will only contains two fields from "my_table".
so, I would like to prevent a user
from selecting other columns from the table and dragging them into the "Expression" zone.

The only thing I would allow him or her to do, is to select columns from the selecting list expression zone.

Is it possible to forbide selecting fields in the table and to permit only selecting columns from existing lines in the "expression zone"?

Thanks.
Rosière Fontaine | email
September 29 2009, 03:46 AM
You should handle the DatasourceFieldAdding event. E.g.:

queryBuilder1.addDatasourceFieldAddingEventListener(new com.adbs.querybuilder.DatasourceFieldAddingEventListener()
{
public void datasourceFieldAddingEventOccurred(com.adbs.querybuilder.DatasourceFieldAddingEvent evt)
{
queryBuilder1DatasourceFieldAddingEventOccurred(evt);
}
});

private void queryBuilder1DatasourceFieldAddingEventOccurred(com.adbs.querybuilder.DatasourceFieldAddingEvent evt)
{
evt.abort = true; // this will prevent filed selection
}
Eugene Starkov | email
36 mins since original post
Thank you Eugene,

With in the same context as my first question, I would also like to prevent a user from removing an item, or inserting an item, or change the items' order in the zone "expression".

In the zone expression, the only permitted changes on the "Expression" column, are: to select a field, and to clean it, by typing an empty string '' in the field's name, if a field is selected by mistake.

In this case, which listener should I use?
Rosière Fontaine | email
2 weeks, 2 days since original post
You need to handle events DatasourceFieldRemoving and GridCellValueChanging. Both of them contains "abort" member to prevent unwanted changes.
Eugene Starkov | email
2 weeks, 2 days since original post
This topic is closed