getTabRelationNameAt returns null

Questions and answers for designing and implementing forms in Servoy

getTabRelationNameAt returns null

Postby sarar » Mon Jan 07, 2013 12:43 am

I am adding multiple tabs from multiple new forms at runtime. For each tab I create a new relation with a unique name. The display of the tab seems to works correctly-> the related records display
When I loop through the tabs later in the program the get tab relation funtion returns null
Even if I try to get the relation name immediately after the addTab, I get a null.

My tab creation:
Code: Select all
elements[tabname].addTab(_form,ctab,ctabdisplay,null,null,null,null,rel,ntabnum)
forms[_form].controller.recreateUI()
forms[_form].controller.loadAllRecords()


the debugger does show a value JSrelation for variable rel

but
Code: Select all
elements[tabname].getTabRelationNameAt(ntabnum)

return null
sarar
 
Posts: 14
Joined: Wed Nov 14, 2012 5:01 pm

Re: getTabRelationNameAt returns null

Postby rgansevles » Mon Jan 07, 2013 11:04 am

Sarar,

What is ntabnum in your example?
When the value is larger then the number of existing tabs, the tab will be added at the end, so not at the requested position.
For example if you have 1 tab and you add a tab on position 5 it will be added to position 2
getTabRelationNameAt(5) will return null.

Note that the index is 1-based, so index 1 refers to the first tab, not the second.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: getTabRelationNameAt returns null

Postby sarar » Mon Jan 07, 2013 11:50 pm

Hi Rob,
ntabnum is the tab I am at
I don't think this is the issue as the getTabNameAt returns the correct tab name.
i have done further testing and the relation is simply not being attached to the tab at all.

Here is the code I am using for the relation setting. Maybe it is something in here:
_datasource = the main table on the form
uri is a temporary datasource. I have verified and the values are set correctly.

Code: Select all
var crelname = application.getUUID().toString()
var rel = solutionModel.newRelation(crelname,_datasource,uri1,JSRelation.INNER_JOIN)
rel.newRelationItem('itemid','=','itemid')
elements['tabacc'].addTab(_form,ctabname,ctabname,null,null,'#000000','#BBCCEE',rel,natnum)


Any ideas would be most appreciated

Thanks
sarar
 
Posts: 14
Joined: Wed Nov 14, 2012 5:01 pm

Re: getTabRelationNameAt returns null

Postby jdbruijn » Tue Jan 08, 2013 9:37 am

i'm not sure, but i think you have to use the relation name in addtab instead of the rel object.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: getTabRelationNameAt returns null

Postby sarar » Tue Jan 08, 2013 10:24 pm

Thanks!
the relation name now comes up.

Unfortunately it is not respected.

After adding the tab, I do
Code: Select all
forms[_form].controller.recreateUI()
forms[_form].controller.loadAllRecords()


where _form is the new form on the tab and all records in the table I just created show on the tab not just the foundset based on the relation with the main form
Do I need to reload something from the main form as well to force the relation to be respected?
sarar
 
Posts: 14
Joined: Wed Nov 14, 2012 5:01 pm

Re: getTabRelationNameAt returns null

Postby jdbruijn » Wed Jan 09, 2013 10:23 am

I dont know what kind of form you put on the tab, but normally you dont have to do recreateui or load records. If the relation is created correctly it should show the correct data on the tabform.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 12 guests