controller.loadRecords(id)

Questions, tips and tricks and techniques for scripting in Servoy

controller.loadRecords(id)

Postby IT2Be » Thu Feb 12, 2004 5:55 pm

I add records to a foundset and add the id to an array. Later I use that array to print the forms based on that array. I do the following for that. Unfortunately the foundset is bigger than what I defined. What do I do wrong:

Code: Select all
var dataset = arguments[0]; //taken from another foundset into the method
var ID = new Array(dataset.getMaxRowIndex()); //define array

for (var i = 1 ; i <= dataset.getMaxRowIndex(); i++)
{
   if (i > 1)
      controller.duplicateRecord();   //I duplicate this record if i > 1
            
   ID[i-1] = lettersid; //add the id to the array
}

forms.lettersPrint.controller.loadRecords(ID); //call form/records based on arry
forms.lettersPrint.controller.print(false, true);//print records


I checked the dataset and the ID array. They both have 3 records in there but printing gives me all records...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Jan Blok » Fri Feb 13, 2004 1:06 am

What you are trying todo is not possible (but might be a good idea to build)
Move sample code of loadRecords(...) to see all possibilities of use
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby jcompagner » Fri Feb 13, 2004 1:08 am

first convert the ID's to a dataset:

var set = databasemanager.convertToDataset(ID);

and use that set in youre load
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby IT2Be » Fri Feb 13, 2004 11:00 am

:oops: Should/could have know! Thanks guys 'problemo solvado'...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby IT2Be » Fri Feb 13, 2004 11:51 am

Well, it looks like there still is an issue. Instead of:
Code: Select all
forms.lettersPrint.controller.loadRecords(ID);
forms.lettersPrint.controller.print(false, true);

I now have:
Code: Select all
var set = databaseManager.convertToDataSet(ID);

forms.lettersPrint.controller.loadRecords(set);
forms.lettersPrint.controller.print(false, true);


This gives me a set of 2 selected records where the array (ID) and dataset (set) contain 3 records (I doublechecked this)!!!

When I now do:
Code: Select all
var set = databaseManager.convertToDataSet(ID);

forms.letters.controller.loadRecords(set)
forms.lettersPrint.controller.loadRecords(foundset);
forms.lettersPrint.controller.print(false, true);


Where the form letters is the original form on which I created the array...
The result is the expected 3 records?

Do I do something wrong or is this a bug?
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby jcompagner » Fri Feb 13, 2004 12:06 pm

this could als be youre code yes?

Code: Select all
var set = databaseManager.convertToDataSet(ID);

controller.loadRecords(set)
forms.lettersPrint.controller.loadRecords(foundset);
forms.lettersPrint.controller.print(false, true);


(so you are in the context of the letters form.. )
To be sure that you set the same foundset...

what does the maxRecordIndex say when you load the records?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby IT2Be » Fri Feb 13, 2004 1:48 pm

Below my factfinding mission:

Here I load the set into the basic form and load the foundset into the print form. All goes well...
Code: Select all
controller.loadRecords(set)
//controller.getMaxRecordIndex result = 3
forms.lettersPrint.controller.loadRecords(foundset);
//forms.lettersPrint.controller.getMaxRecordIndex result = 3


Here I don't do a controller.loadRecords() and the foundset = 2. I only print two records...
Code: Select all
//controller.loadRecords(set)
//controller.getMaxRecordIndex result = 2
forms.lettersPrint.controller.loadRecords(foundset);
//forms.lettersPrint.controller.getMaxRecordIndex result = 2


Here I again don't do a controller.loadRecords() and the foundset is again 2. When loading the set (and not the foundset) into the print form I again have 3 records but can only print 2???
Code: Select all
//controller.loadRecords(set)
//controller.getMaxRecordIndex result = 2
forms.lettersPrint.controller.loadRecords(set);
//forms.lettersPrint.controller.getMaxRecordIndex result = 3


In all cases I didn't use a seperate foundset (check in print form) and checking the print form to use a seperate foundset doesn't change the result.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Jan Blok » Mon Feb 16, 2004 11:36 am

Could you check the default sort on your forms, one of must be using a related field sort with one field being null in the database (and is due to db join for sort not returned)
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby IT2Be » Mon Feb 16, 2004 11:53 am

Hai Jan, thanks for your effort! Just wanted to tell you that...

In this case I don't use any (default-) sort on both the forms. So that can't be the issue... I have attached the properties of the forms. Left is the 'basic' form right = the 'print' form.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Jan Blok » Fri Feb 20, 2004 2:47 pm

we are unable to reproduce this at all, can you sent us your solution or provide a small sample which shows this?
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam


Return to Methods

Who is online

Users browsing this forum: No registered users and 24 guests

cron