Custom dynamic lists

Post any suggestions or enhancement requests about the Verj.io platform or this Forum

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Custom dynamic lists

#1

Postby Segi » Mon Nov 27, 2017 5:02 pm

I have had cases where I want to have a dynamic list that is built at run time and is not directly tied to a database source like most other dynamic lists which are sourced from a SQL query.

For example, a form that is used to generate a report which displays a year dropdown. This dropdown contains the previous year, the current year and the following year.

In order to do this, you MUST tie the field to any dynamic list just for the sake of Ebase considering it a properly set up dynamic list. Once you do this, you are free in the before page event to do something like this:

Code: Select all

fields.REPORTYEAR.list.buildList();
fields.REPORTYEAR.createCustomList();
fields.REPORTYEAR.list.add(new Date().getFullYear()-1);
fields.REPORTYEAR.list.add(new Date().getFullYear());
fields.REPORTYEAR.list.add(new Date().getFullYear()+1);
If you do not tie the field to a dynamic list first, you will get an error on the first line:
TypeError: Cannot call method "buildList" of null

It might seem like a small detail but it would be nice to remove this requirement of tying the field to a random DL just so you can build a dynamic list at run time. It seems weird to have to tie the field to a DL that has nothing to do with what the drop down will ultimately contain.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: Custom dynamic lists

#2

Postby Jon » Tue Nov 28, 2017 9:46 am

Segi,

You don't have to configure the field to use a Dynamic List if you are going to create your own list with createCustomList(). You can just leave the list fields blank in field properties - but then you should also remove the buildList() line from your script. The buildList() method applies specifically to a Dynamic List - it has no meaning for the other list options.

Regards
Jon
0 x


Who is online

Users browsing this forum: No registered users and 5 guests