currentcontroller.maxRecordIndex

Questions, tips and tricks and techniques for scripting in Servoy

currentcontroller.maxRecordIndex

Postby Harjo » Tue Jun 03, 2003 9:48 am

This method:
currentcontroller.recordIndex = currentcontroller.maxRecordIndex

isn't working anymore! Also in the CRMdemo it isn't function anymore.

am I doing something wrong?
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby maarten » Tue Jun 03, 2003 11:05 am

This is old syntax that shouldn't be there in the CRM.

Proper syntax:

currentcontroller.recordIndex = currentcontroller.getMaxRecordIndex()
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby Harjo » Tue Jun 03, 2003 1:15 pm

Oke, that's fixed.
but it still does'nt work all the time.

If i open the solution, it works (it goes to the last record) but after I click a field label (sorting!) and my list is sorted, it won't go to the last record! (total of 10.000 records!)
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby Jan Aleman » Tue Jun 03, 2003 1:36 pm

Why don't you do an invert sort if you want to go to the last record? In some desktop databases it is very common to go with one click to the last record as all data is always local.In SQL based backends this is not very common and depending on your foundset it can be very expensive. Servoy will by default get the first 200 rows as you might have noticed in the controller. Servoy simply doesnt know what your last record is, you could know by performing a count (servoy even has a function for that) but that can be an expensive operation depending on your amount of data. If you still want to go to your last record anyhow you can do:

Code: Select all
while (controller.recordIndex < controller.getMaxRecordIndex())
{
   controller.recordIndex = controller.getMaxRecordIndex();
}


The above isnt a problem if you have 10k rows but I wouldnt recommend it in large tables. It also undermines the true client/server concept of Servoy.

I still recommend the inverse sorting to go to the last record as then you leave the sorting to be done by the backend SQL server that has been optimized to perform this kind of operations.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby Harjo » Tue Jun 03, 2003 1:46 pm

Oke thanks!
That makes it clear!
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

How about using a seperate table to keep dthe row counts

Postby Tony_Adrian » Tue Jun 03, 2003 2:16 pm

I haven't tried this yet but here's my knee-jerk thought:

Have Servoy or the backend automatically increment a seperate table every time records are added or deleted. Place the appropriate dataprovider on the form and you would have a live total row count at all times. As I said - I haven't tried this but it sounds like a good solution.


...................row_count
employee.........48
invoices............100002
payments..........79000
customers..........590

Add another payment:

....................row_count
employee............48
invoices...............100002
payments.............79001
customers............590




My current end users feel secure seeing the total number of records at all times because they are used to it.

I appreciate any thoughts on this.
Tony Adrian RN

Nursing Data Inc.
A Medicare Approved Software Billing Vendor
Database/Document Management for the Health Care Industry
Servoy, Sybase, Lotus Domino/Notes
Tel: (337) 394-8548
Fax: (337) 394-8504
sales@NursingData.com
Tony_Adrian
 
Posts: 42
Joined: Thu Apr 24, 2003 3:24 am

Postby Jan Aleman » Tue Jun 03, 2003 2:36 pm

Good idea, downside is that you if you add/delete records outside of Servoy it wouldnt reflect a correct count. Also this solution will only work for counts of complete tables what if somebody does a find and has a large foundset.

In many cases you can simply use the count functions Servoy provides:
getTableCount for an entire count and
getFoundSetCount for the foundset
Just make sure you don't use them on very large tables or buy a very big databaseserver ;-)

You could also consider maintaining rowcounts using a trigger on your backend database.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth


Return to Methods

Who is online

Users browsing this forum: No registered users and 8 guests