JavaScript get table.tablename object

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

vin@haarlem
Ebase User
Posts: 8
Joined: Wed Aug 14, 2013 9:18 am

JavaScript get table.tablename object

#1

Postby vin@haarlem » Wed Nov 13, 2013 2:22 pm

I'd like to fetch the table.tablename object dynamically in a serverside JavaScript so I can reuse a script in multiple forms with different tablenames.

Something like the "event.getOwner().elementName".

Example:

I use a form with a dropdown that runs a script at onChange. The script fetches the value of the dropdown and does some magic stuff. The dropdown is part of a table so I use table.tablename.dropdown.value to get the value. I'd like to get it as following (for example):

otable = event.getTable();
otable.dropdown.value;

Is that possible?
0 x

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

#2

Postby Jon » Wed Nov 13, 2013 3:43 pm

Sorry Vin, but I don't understand this question. What are the exact relationships between the event, table and dropdown?

Regards
Jon
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

#3

Postby HarryDeBoer » Thu Nov 14, 2013 1:16 pm

Hi Vin

Not quite sure if this is what you looking for but if you point the onchange events to one script you could do:

var tblnm = event.owner.elementName;
var i = tables.getTable(tblnm).rowCount //rowcount as example

Regards, Harry
0 x
Kind regards,

Harry

vin@haarlem
Ebase User
Posts: 8
Joined: Wed Aug 14, 2013 9:18 am

#4

Postby vin@haarlem » Wed Nov 20, 2013 9:14 am

Thanks Harry for pointing us in the right direction. You're code doesn't fulfill our needs completely because "event.owner.elementName" will give us the fieldcontrol instead of the tablename. Therefore we need to add the tablename to the fieldcontrol and split the name so we get the tablename. The code below works but I still hope that the same thing is possible without adding the tablename to the fieldcontrol like this: "FIELDCONTROL1@@TABLE_NAME".

Code: Select all

var owner = event.owner.elementName;
var tableName = owner.substring(owner.indexOf('@@'));
var myTable = tables.getTable(tableName);
var neededValue = myTable.DROPDOWN.value;
Last edited by vin@haarlem on Wed Nov 20, 2013 9:16 am, edited 1 time in total.
0 x

vin@haarlem
Ebase User
Posts: 8
Joined: Wed Aug 14, 2013 9:18 am

#5

Postby vin@haarlem » Wed Nov 20, 2013 9:15 am

...
0 x

vin@haarlem
Ebase User
Posts: 8
Joined: Wed Aug 14, 2013 9:18 am

SOLVED

#6

Postby vin@haarlem » Wed Nov 20, 2013 12:19 pm

Problem solved! This is the right and fully dynamic code:

Code: Select all

var field = event.owner.getField();
var fieldName = field.elementName;
var tableName = fieldName.substring(0, fieldName.indexOf('-'));
var myTable = tables.getTable(tableName);
var neededValue = myTable.DROPDOWN.value;
0 x

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

#7

Postby Jon » Wed Nov 20, 2013 2:13 pm

You should also be able to get the table name from the table column:

Code: Select all

var field = event.owner.getField();
var tableName = field.table.elementName;
0 x


Who is online

Users browsing this forum: No registered users and 6 guests