Page 1 of 1

getTabRelationNameAt returns null

PostPosted: Mon Jan 07, 2013 12:43 am
by sarar
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

Re: getTabRelationNameAt returns null

PostPosted: Mon Jan 07, 2013 11:04 am
by rgansevles
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

Re: getTabRelationNameAt returns null

PostPosted: Mon Jan 07, 2013 11:50 pm
by sarar
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

Re: getTabRelationNameAt returns null

PostPosted: Tue Jan 08, 2013 9:37 am
by jdbruijn
i'm not sure, but i think you have to use the relation name in addtab instead of the rel object.

Re: getTabRelationNameAt returns null

PostPosted: Tue Jan 08, 2013 10:24 pm
by sarar
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?

Re: getTabRelationNameAt returns null

PostPosted: Wed Jan 09, 2013 10:23 am
by jdbruijn
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.