How to add "Please select" to custom build list?

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

How to add "Please select" to custom build list?

#1

Postby xren » Tue Jul 09, 2013 8:29 pm

Hi,

-----------
I have dropdown list which should be a dynamic list.
However, choosing which dynamic list will depend on user's input to anther field. For example: if user set value 1 to field 1, then field 2 is the dynamic list will use list a. if user set value 2 to field 2, then field 2 will use list b.

How can this be done?
--------------

This had been fixed. However, as my last post, the "Please select" does not show up in the custom build dynamic list. How can this be add? for case user don't want to select then this value will be null.


Thank.
Last edited by xren on Mon Jul 15, 2013 2:00 pm, edited 1 time in total.
0 x

User avatar
jig
Ebase User
Posts: 30
Joined: Sun Oct 09, 2011 10:16 am
Location: UK

#2

Postby jig » Wed Jul 10, 2013 10:48 am

Hi,

There are a few options depending upon your exact requirements:

1) Create One dynamic list (backed by a database table) and use the &&QUERY in WHERE clause SQL to filter values in this list depending upon the value chosen in 'Field 1'
2) Use 'createCustomList()' in JavaScript. E.g. http://www.schnellsolutions.co.uk:3131/ ... List%28%29. Using 'createCustomList()' you can also use values from an Ebase table to build a list. If you want, we would be happy to share an example :)

Hope this helps!

Regards
Jignesh
0 x
Regards,
Jignesh

Jignesh Vaducha, MSc, MCA
Mobile: +44 (0) 77 325 47 112
Telephone: +44 (0) 1462 488 311
Email: jignesh@schnellsolutions.com

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

#3

Postby xren » Thu Jul 11, 2013 1:10 pm

More specifically,

I have field 1 - a date, field 2 a drop down list - low, high, medium.

field 4 is a dynamic list. If date is Monday and field2 is low, then the dynamic list for field 4 will be list 1. If date is Tuesday and field 2 is low, the dynamic list for field 4 will be list 2, so on and so on.

It will be great if you can provide a sample.
BTW, the link in your post does not work.

Thank you!
0 x

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

#4

Postby xren » Thu Jul 11, 2013 2:15 pm

buildlist is the FPL function. Is there a corresponding function in javascript?
and how to do that in javascript?
0 x

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

#5

Postby Jon » Thu Jul 11, 2013 4:15 pm

I think you can achieve what you want by having a function that queries the database for your list entries. Here's a template you can use, but you will certainly have to modify it for your requirements. It accepts a single variable and issues different SQL depending on this. At a minimum, you will have to set the database connection name, and the values and SQL statements inside the switch/case logic.

Code: Select all

function getListFromDatabase(var1)
{
  var connectionName = "DATABASE_CONNECTION_NAME";                 // This must be changed to a valid database connection name
  var sql;
  switch (var1)
  {
  	case "value1":
  		sql = "select xxx from tabyyy";
  		break;
  	case "value2":
  		sql = "select xxx from tabyyy";
  		break;	
  }
  var con = system.getDatabaseConnection(connectionName);
  var stmt;
  var rs;
  try
  {
    stmt = con.prepareStatement(sql);
    rs = stmt.executeQuery();
    var result = [];
    while (rs.next())
    {
       result.push(rs.getString(1));
    }
    return result ;
  }
  finally
  {
    // It is very important to close any open result sets, statements and connection in this manner
    //  otherwise there will be a resource leak.
    if(rs) rs.close();
    if(stmt) stmt.close();
    if(con) con.close();
  }
}
Then to call this and build the list you will need something like this:

Code: Select all

var list = fields.LISTFIELD.createCustomList();
var entries = getListFromDatabase(fields.VARIABLEFIELD.value);
for each (var ent in entries)
{
  list.add(ent);
}
Good luck
Jon
0 x

User avatar
jig
Ebase User
Posts: 30
Joined: Sun Oct 09, 2011 10:16 am
Location: UK

#6

Postby jig » Fri Jul 12, 2013 6:50 am

Hi,

You can also solve this using &&QUERY in WHERE clause of your Dynamic list SQL. E.g.

Code: Select all

Select COLUMN_1,COLUMN_2,COLUMN_3,COLUMN_4 from TABLE_1 where DAY_COLUMN='Monday' and COLUMN_5='low'
where DATE_COLUMN='Monday' and COLUMN_5='low' is build using &&QUERY.

If you still want me to send you an Example, please send me an Email as I don't have your Email id :)

Not sure why the link does not work for you...but you can try this one:

Code: Select all

http://www.schnellsolutions.co.uk:3131/ufs_dev/doc/javadocAPI/com/ebasetech/xi/api/WebFormFieldOrColumn.html#createCustomList()
0 x
Regards,
Jignesh

Jignesh Vaducha, MSc, MCA
Mobile: +44 (0) 77 325 47 112
Telephone: +44 (0) 1462 488 311
Email: jignesh@schnellsolutions.com

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

#7

Postby xren » Fri Jul 12, 2013 2:08 pm

It appears now! I set this field dynamic list to first build. then when the corresponding fields changes, trigger script to build this list.

However, there is no "Please select ..." showed up as other drop down list. So when user don't pick, then the value is null.

How can this be add ?
0 x


Who is online

Users browsing this forum: No registered users and 21 guests