table component - foundset by query

Forum to discuss the new web client version of Servoy.

table component - foundset by query

Postby swingman » Mon Jun 15, 2020 5:17 pm

Hi all,

I'm using the table-component in Servoy 2020.03 and it it woking really well when I bind it to the form foundset or a related foundset.
However, I have a table where I'd like to load news stories. To generate the list I use the following query:

Code: Select all
var query = "SELECT id FROM news_articles WHERE news_articles.tsv @@ to_tsquery(?) ORDER BY pub_date";


on a normal form I can simply do

Code: Select all
forms.news.foundset.loadRecords(query, args);


The table component has a foundset but this looks like a foundset setter, not a full foundset node.
The component also has what seems to be a callback,

Code: Select all
onViewPortChanged(start, end)


How do I put this together? What kind of foundset do I need to use?
Does anyone have a snippet of sample code showing how this is all put together?

Thanks,

Christian
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: table component - foundset by query

Postby Andrei Costescu » Tue Jun 16, 2020 10:27 am

You are talking about the servoy-extra table component right? So the name of it's foundset property is "foundset".
You should be able to access that (assuming the table already has a foundset) directly through:

Code: Select all
elements.myExtraTable.foundset.foundset.loadRecords(query, args);

More details on how to use foundset typed properties from scripting and how to assign new foundsets to an existing property or complete new foundset property values can be found here: https://wiki.servoy.com/display/DOCS/Fo ... ertyaccess
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: table component - foundset by query

Postby swingman » Wed Jun 17, 2020 3:31 pm

Code: Select all
elements.myExtraTable.foundset.foundset.loadRecords(query, args);


I noticed I could do this, bit U thought the foundset.foundset bit of syntax was very odd, so I did not persue it...
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: table component - foundset by query

Postby swingman » Thu Jun 18, 2020 12:19 pm

One warning about the servoy-extras table component in case someone else gets into trouble:

Do not try to hide the header by using css like this (mine has a style-class called news-table):

Code: Select all
.news-table>thead>tr  {
   height: 0px;
}


If you do this the table stops redrawing. I have been debugging my screens for a day going around in circles before realising this.
If you add a little height on the header everything works fine:

Code: Select all
.news-table>thead>tr  {
   height: 2px;
}
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 1 guest

cron