Are controller specific to a table or not?

Just having a problem with my custom controller. Can I use the same controller to control layouts from different tables?

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?

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…

No, is not possible yet!
Look here: http://forum.servoy.com/viewtopic.php?t … controller

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”!

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.

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

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();
}

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?

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..

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

that is exactly what JSDatabaseManager does for you with getFoundsetCount

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

Harry Catharell:
‘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.