Remove EditableTable Add feature where EditableTable List Length is greater than 4

I am using an EditableTable widget to display a list of answer possibilities corresponding to 1 question. I can successfully add, update or delete a record.

However, I want to set a maximum of answer possibilities with a question, e.g. 1 question with 4 answer possibilities. 

I found this link, but I can't figure out how to modify this code to only remove the Add feature where EditableTable.List.Length >= 4.

Only thing that I could figure out was a variable css class depending on the list length. However, the standard Ajax Refresh inside of the EditableTable will not refresh the CSS class. The Add Record button only goes away when fully reloading the page.


Can you share an OML?

Solution

Hi Maurits,

I attached a sample .oml that I think that fulfills your requirement.

Basically, you have a CSS class conditionally. If you have more than 4 elements in the list, it should set the Add property to display:none. Otherwise, it should set the Add property to display:initial.

Regards!


Solution

Bruno Marques wrote:

Hi Maurits,

I attached a sample .oml that I think that fulfills your requirement.

Basically, you have a CSS class conditionally. If you have more than 4 elements in the list, it should set the Add property to display:none. Otherwise, it should set the Add property to display:initial.

Regards!


Thank you, this works.

However, when pressing TAB or Enter, it will still add a new record.
Is it also possible to disable this feature with an If statement?


Hi Maurits,

In the previous oml sample I forgot to set the style class of the last input of the Editable Table. 

Because, like is explained in this article, you need to define the Javascript at a screen level to prevent the tab key to create new records (this is already done in the sample). Then you need to assign this Javascript to the last input of the editable table (this is missing).

I am unable to edit my previous post, so I can't replace the wrong oml sample. With the explanation given, you should be able to do it. Let me know if you need that I upload the file again.

Regards!

Bruno Marques wrote:

Hi Maurits,

In the previous oml sample I forgot to set the style class of the last input of the Editable Table. 

Because, like is explained in this article, you need to define the Javascript at a screen level to prevent the tab key to create new records (this is already done in the sample). Then you need to assign this Javascript to the last input of the editable table (this is missing).

I am unable to edit my previous post, so I can't replace the wrong oml sample. With the explanation given, you should be able to do it. Let me know if you need that I upload the file again.

Regards!

Got it to work, thanks!