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

Master - Detail with empty Details

General questions regarding the development with JVx.

Master - Detail with empty Details

Postby JuFi » Tue Oct 30, 2018 11:23 am


I have a table which I use as a master and the corresponding details are in an other table. I have connected those two via the setMasterReference function and this is working perfectly.
My problem is that not every row in my master has a corresponding detail row. In this case the detail editors become disabled/not editable.

How can I make those editors editable and also save the user input into a new row in the details table.
Thank you in advance!
Posts: 12
Joined: Thu Oct 11, 2018 2:20 pm

Re: Master - Detail with empty Details

Postby rzenz » Tue Oct 30, 2018 11:37 am

If there is no row in the DataBook you can only add a new one, there is no "new row by default" mechanic in JVx. So what you must do is listen to selection changes on the master and change the detail accordingly. Without doing much testing, something like this:

Code: Select all

// Later in the same class.
private void doAddDetailRowIfNeeded(DataBookEvent pDataBookEvent) throws ModelException
    if (detailDataBook.getRowCount() == 0)

private void doProcessNewDetailRow(DataBookEvent pDataBookEvent) throws ModelException
    if (detailDataBook.getRowCount() == 1 && detailDataBook.isInserting())
        // Save or revert here.
User avatar
Posts: 36
Joined: Mon Dec 12, 2016 1:40 pm
Location: Vienna, Austria

Re: Master - Detail with empty Details

Postby Support@SIB » Tue Oct 30, 2018 12:49 pm

Is it a big problem for the user to insert a new record, e.g. press a "New record" button or is it a complex use-case?

Otherwise, the given example would help to implement your requirement. Every UIEditor needs a bound datarow/databook otherwise it's disabled. Sure, it's possible to use simple UITextEditor and sync the values manually, but this isn't recommended and needs more code and work.
User avatar
Posts: 353
Joined: Mon Sep 28, 2009 1:56 pm

Return to Development