This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Filter Combobox

General questions regarding the development with JVx.

Filter Combobox

Postby lucdep » Fri Apr 12, 2019 8:49 am

Hi,

I have the following challenge in my multi-company application:

1. Data structure:

master table Group

sub table Company with a Group_ID field

table User has a Group_ID and Company_ID field (both combobox);
Users can be:
- Administrator with access to all Groups and all Companies (Group_ID and Company_ID empty);
- Groupadministrator with access to only one Group, but all Companies within that Group (only Group_ID selected)
- Normal User with access to only one Company, hence only one Group too (both Group_ID and Company_ID selected)

tabel Relation
every Relation is owned by a Company and has a Company_ID field (combobox)

2. Problem
In both the UserWorkscreen and the RelationWorkscreen the Company_ID combobox should be filtered in accordance to the Group_ID (no filtering if no Group_ID selected, filtering on Group_ID when a Group is attributed.

I have tried to filter with setAdditionalCondition method from ILinkedCellEditor, but this apparently doesn't work, because the combobox remains completely empty when filtering)

Any idea how to make this work?

Luc
lucdep
 
Posts: 53
Joined: Wed Oct 10, 2018 12:01 pm

Re: Filter Combobox

Postby johnit » Fri Apr 12, 2019 5:33 pm

I guess your additional condition is wrong, e.g. the wrong column name? This works like a charm.

But if you want it more automatic, simply create a combined foreign key in the database for your users table.
Set group_id, company_id to company table group_id, id.

Otherwise it would be possible to set a group which is different to the group of the company. This shouldn't happen.

If you have such combined foreign key, JVx will set the filter automatically for your.


In the next step, you will find out that it will be a lot of work to restrict every storage manually with your group_id or company_id? You could overwrite put(String, String) in Session.java and set a restrict condition on every storage and sub storages (= storages for comboboxes). This requires that you have the same column names to solve it generic!
johnit
 
Posts: 45
Joined: Fri Nov 16, 2012 5:58 pm

Re: Filter Combobox

Postby lucdep » Sun Apr 14, 2019 12:26 pm

Hi johnit,

Thank you very much for your solution, the combined foreign keys work like a charm!

Can you give some more details on your remark on the put method in the session? That's not very clear to me.

Luc
lucdep
 
Posts: 53
Joined: Wed Oct 10, 2018 12:01 pm


Return to Development