Page 1 of 1

Are controller specific to a table or not?

PostPosted: Sat May 01, 2004 4:50 pm
by swingman
Just having a problem with my custom controller. Can I use the same controller to control layouts from different tables?

PostPosted: Sat May 01, 2004 8:18 pm
by maarten
Normally one would use the currentcontroller node (under Globals).
It simply executes on the form that's active.
( the(main) form showing next to the controller ).
eg:
"Go to first record" would be like a script attached to the controller form
saying: currentcontroller.recordIndex = 1
Attached to a button on the controller form, it will trigger on all main forms that appear next to the controller form.

If this info doesn't help you, maybe you can describe an example of what you would like to do?

PostPosted: Mon May 03, 2004 12:22 am
by swingman
My buttons work fine with currentcontroller, the problem is with a text label:

I wanted a text label on the controller, displaying "12 of 31" records.
So, I added a label with

"%%recordIndex%% of %%maxRecordIndex%%"

on the controller.

But, when I change the active form, the values displayed seem to be related to the controller table, rather than the active form.

I would not expect a controller have a "tablename" property...

PostPosted: Mon May 03, 2004 8:10 am
by Harjo
No, is not possible yet!
Look here: http://forum.servoy.com/viewtopic.php?t ... controller

PostPosted: Mon May 03, 2004 10:33 am
by swingman
Thanks HJK!

I will move my "x of y" records to the main forms.

Also, I notice that the controller in the "crm" solution is based on a table called "main".

This will solve another problem I have with my controller:
as it is based on a table with "servoy_row-bgcolor", my controller changed colour too, even though it is set to "record view"!

PostPosted: Sun May 09, 2004 12:45 pm
by jcompagner
you can get an "xxx of yyyy" in youre custom controller if you want.
Just build "xxx of yyyy" in a global.
And set that global in a onRecordSelection of the forms that uses that custom controller.

PostPosted: Sun May 09, 2004 1:09 pm
by Harry Catharell
I am just trying to resolve what I will show and control from within a custom controller and I would like input on how everybody is working within the limit (sorry, Jan, I mean feature !) of a maximum value of 200 records being returned by the getMaxRecordIndex.

So if you have 300 records in the table or found set etc what would you show as the 'yyyy' value in the 'xxxx' records of 'yyyy' ?

Cheers
Harry

PostPosted: Sun May 09, 2004 1:24 pm
by jcompagner
it is not really the absoluut maximum. it is the initial maximum.

if you really want the complete count you can do that with
databasemanager.getFoundSetCount(foundset)


of if you know that there aren't thousands of rows you can iterate one time over them..

while(controller.recordIndex < controller.getMaxRecordIndex())
{
controller.recordIndex = controller.getMaxRecordIndex();
}

PostPosted: Sun May 09, 2004 4:02 pm
by swingman
I have been reading through the Sybase ASA manuals and I'm wondering whether it would make sense to have a table of recordcounts with records for all the large tables, where the counts are updated using triggers on INSERT and DELETE?

PostPosted: Mon May 10, 2004 11:36 am
by jcompagner
that doesn't work for finds (user finds or related things)
you only have then hard limits of hte complete table. And those shouldn't be to hard for a database to give anyway..

PostPosted: Mon May 10, 2004 11:46 am
by Harry Catharell
Excuse any SQL naivety but could we not retrieve total records through a SQL query using an aggregate function ?

As in :

SELECT COUNT(*) AS rec_count
FROM client;

Also adding a 'WHERE' clause to filter for a found set count ?

If this is a low overhead process then it may not mean that you have to also have data stored in reference tables and have to handle that administrative processing.

Apologies, but I have been reading my SQL Primer book !! I am not sure how this would be wrapped inside Servoy merthods yet - just writing out loud !!

Harry

PostPosted: Mon May 10, 2004 11:54 am
by jcompagner
that is exactly what JSDatabaseManager does for you with getFoundsetCount

PostPosted: Mon May 10, 2004 12:30 pm
by Harry Catharell
Ye Gods - I'm a SQL programmer - It's a miracle !!

No, it's OK - I've just thrown cold water on my face and woken up - I'm only human after all :-(

In reality, I suppose that I am looking for guidance on what is a 'low overhead' process and what is 'expensive' ?

I know that Servoy has initial limits built in to optimise response.

And I recall that the getFoundSetCount function has the 'expensive' warning attached to it.

I guess that I really need to create a mass of dummy records and run some tests.

I cannot believe that any process run in Servoy/SQL would be >= FileMaker's unstored calculation results to get :
"rec 'x' of 'y' found from 'z' total records"

'swingman' - let me know what you decide to do as I am very interested.

Harry

PostPosted: Mon May 10, 2004 1:23 pm
by swingman
Harry Catharell wrote:'swingman' - let me know what you decide to do as I am very interested.


I'm exploring the issues of moving certain projects to Servoy, so I'm not ready to do any tests just yet. I think I will have to look at how important it is for the client to know exactly how many records they have found and decide to whether to display "1 of 200+" or an exact count.