onTabAction

Discuss all feature requests you have for a new Servoy versions here. Make sure to be clear about what you want, provide an example and indicate how important the feature is for you

onTabAction

Postby bobcart » Thu Mar 03, 2005 4:14 am

It would be great if we could fire a script when a tab panel tab is clicked. For example. I have a tab penel with two tabs. One includes a form with a table of records and the other shows a detial view for a given record. In this case, I need to set a global used in a relationship to show some related records for this record. To do this, I now have to have a seperate button to set the global and switch the tab rather than just tieing the set global statement to a method run when the tab is clicked.

I can work around it in this case with a onShow event for the form, but with a more comples situation, having an onTabAction event would be a clean and elegant way to do it.
bobcart
 
Posts: 214
Joined: Fri Nov 21, 2003 8:01 pm
Location: Melbourne (AUS)

Postby pbakker » Fri Mar 04, 2005 9:45 am

Would coincide with this request a bit, I think: http://forum.servoy.com/viewtopic.php?t=4039&highlight=

I would really like this onTabAction as well, as long as we then can determine which tab is was that fired the action. Because I wouldn't like to make a method for every tab, but one global method, attach it to every tab and then, somehow determine by which tab it was fired.

So, I do vote for this one too, but I'd like to have it a bit extended:
- onTabAction
- getSelectedTabName
- getTabNameAt

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby jcompagner » Fri Mar 04, 2005 12:01 pm

you could use the onShow and then getMethodTriggerFormName() in a global method.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8846
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby pbakker » Fri Mar 04, 2005 12:16 pm

Not if I have multiple tabs with the same form.

Consider the following situation:
- I have product records with a column type, which can hold values 1, 2 or 3
- I have a customer form and the customer has products of all three types
- On the custoemr form, I have a tabpanel with three tabs, each tab showing a simple, related form, displaying the products table
- The relation used just links the customer to products, but also has a global on the left side, linked to the type column of the products table on the right side.
- Now, when the first tab is selected, I want to set the global to 1, so the tab shows all related records of type = 1
- When the third tab is clicked, the global is set to 3, showing... etc, etc...

This is not possible with onshow and getMethodTriggeredformName. you could add into the equation the getTabTextAt and tabIndex, together with a loop through possible i18n keys that are used for the tabTexts, but that is quite a work around.

And then you have the situation how to avoid all these actions when the form is showed, but not in the tabPanel.

Or am I missing something?

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby jcompagner » Fri Mar 04, 2005 1:43 pm

So you have 3 tabs all displaying the same form over the same relation?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8846
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby pbakker » Fri Mar 04, 2005 1:48 pm

yes, that is the idea
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Odysseus » Fri Mar 04, 2005 4:11 pm

I did something similar ( schedular kind of thing, all days of the week numbered 1 to 7, having tabs for each day, all tabpanels pointing to the same form over the same relation, relation has left side global).
In the onShow of the tabPanel Form, I used global dayOfweek = tab.tabIndex (eventually accomodated for previous tabs).
Simple method, works all the time.
Odysseus

Citizen of Old Europe
Odysseus
 
Posts: 205
Joined: Wed Sep 10, 2003 9:34 pm
Location: Belgium

Postby pbakker » Fri Mar 04, 2005 4:49 pm

ok, but when the form is used in various places, it's not possible to determine when it gets shown in this specific tabpanel.

For example, getMethodTriggerForm will return the name of the form to which the onShow method is attached and the getMethodTriggerElement returns null.

BTW: you could argue that the getMethodTriggerForm should return the name of the form on which the tabpanel is located for onShow and onLoad events and that the getMethodTriggerElement should return the name of the TabPanel for OnShow and OnLoad methods...

Any way that I have overlooked to determine it was shown in the specific tabpanel?
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Odysseus » Fri Mar 04, 2005 5:55 pm

I agree it would be nice to have FORM properties:

runsAsChild (runs inside another form through a tabpanel) which returns true or false

parentFormName: if(runsAsChild) forms[parentformname].element[tabelement].tabindex = 1

In this objectoriented environment this shouldn't be too much trouble :?
Odysseus

Citizen of Old Europe
Odysseus
 
Posts: 205
Joined: Wed Sep 10, 2003 9:34 pm
Location: Belgium

Postby jcompagner » Fri Mar 04, 2005 6:10 pm

you aready know that a form is running as a child or not
if that forums controller is not the currentcontroller....
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8846
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby Odysseus » Fri Mar 04, 2005 6:42 pm

if that forums controller is not the currentcontroller....


:lol:
Heavy week was it ?? Let me guess, you've been appointed forum admin. See it as a promotion, not a punishment....


But your right of course. How would you write this out ?

var thisForm = getMethodTriggerForm()

if(currentcontroller != thisForm.controller)
{
var ParentForm = currentcontroller.name
}

Right ?[/code]
Odysseus

Citizen of Old Europe
Odysseus
 
Posts: 205
Joined: Wed Sep 10, 2003 9:34 pm
Location: Belgium

Postby jcompagner » Mon Mar 07, 2005 12:41 pm

the currentcontroller.getName() is always the main form.

so you have to do something like this:

if(currentcontroller.getName() != getMethodTriggerFormName)
{
// action did happen in a tab
}
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8846
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby pbakker » Mon Mar 07, 2005 1:00 pm

OK, so we can deterine that the form in shown in A tabpanel. But what is I have multiple tabpanels showing the same form?

And what is I cannot determine the which tabpanel it is, because the currentcontroller.getName() function is always the same, because my solution is heavily based on splitpanes and tab(less)panels?

It still aint a foolproof solutions what is now available.

what about the following suggestion:
BTW: you could argue that the getMethodTriggerForm should return the name of the form on which the tabpanel is located for onShow and onLoad events and that the getMethodTriggerElement should return the name of the TabPanel for OnShow and OnLoad methods...


If that would work, we could also get a foolproof situation. The simpler way would be the onTabAction event (at least for us :D )

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby jcompagner » Mon Mar 07, 2005 1:12 pm

for getting the selected tab name you have:

tabpanel.getTabNameAt(tabpanel.getTabIndex());

besides that you can do:

tabpanel.getSelectedTabFormName()
but this you already know.

I agree you you need to know which tabpanel it is that you have to ask that tabname for.

for this you need to have a onTabChange that gets 2 or 3 arguments (the tabname, prevIndex, newIndex)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8846
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby pbakker » Mon Mar 07, 2005 1:32 pm

Yep, for both "tabpanel.getSelectedTabFormName()" and "tabpanel.getTabNameAt(tabpanel.getTabIndex())" it it key to know which TabPanel you are playing with.

So, the suggested onTabChange would definitly help. if possible, a 4th argument, being the form on which the tabpanel resides would also be helpfull, since, with tabpanels in splitpanes in tabpanels in splitpanes etc, you still cannot determine the parent form.

I was thinking of having the ability to add onTabAction methods to the elements you drop onto a TabPanel in designer, but I realise that then you would have an issue with tabs added with addTab at runtime. your solution also works.

So, can this feature be added? :D

Paul

Ps: Tnx for barring with us through the thinking proces...
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Next

Return to Discuss Feature Requests

Who is online

Users browsing this forum: No registered users and 0 guests