Welcome, Guest. Please login or register.
Did you miss your activation email?
Sep. 02, 2010, 07:43:54 PM
53844 Posts in 11998 Topics by 11375 Members
Latest Member: elizablackmore7
News:
 
The PRADO Community » Prado v3.x » General Discussion » Switch Tabview on Callback « previous next »
Pages: [1] Print
Author Topic: Switch Tabview on Callback  (Read 1804 times)
linuxanton
Junior Member
**

Karma: 0
Offline Offline

Posts: 9


View Profile
« on: Mar. 16, 2009, 02:21:22 PM »

Hi,

on my application a want to do the following:

there are 3 TTabViews ( 0 .. 2) in a TTabPanel. On init View 0 is Active. In View 2 i will click to an ActiveImageButton. onCallback View 0 should be Active.

I tried $this->Panel->setActiveViewIndex(0); with no effect. setActiveViewIndex probably is executed when no Callback or Postback ist there.

Can I switch to another View with Javascript? How?

Thanks
Anton
Logged
linuxanton
Junior Member
**

Karma: 0
Offline Offline

Posts: 9


View Profile
« Reply #1 on: Mar. 16, 2009, 02:52:22 PM »

ok, i've found a piece of a solution. In Web/Javascripts/source/prado/controls is in tabpanel.js th funtionality for switching panels. But how can i call the function from ImageButton. Clienscript onClick="Huh"

Logged
piar
Senior Member
***

Karma: 5
Offline Offline

Posts: 144


View Profile
« Reply #2 on: Mar. 16, 2009, 06:05:30 PM »

Try to put TTabPanel on TActivePanel and with your ActiveImageButton do:
Code:
<com:TActiveImageButtonID="ActiveImageButton"
    OnClick="ActiveImageButtonClicked"
    OnCallback="ActiveImageButtonCallback"
    />

Code:
    public function ActiveImageButtonClicked($sender, $param)
    {
      $this->Panel->setActiveViewIndex(0);
    }

    public function ActiveImageButtonCallback($sender, $param)
    {
       $this->ActivePanel->render($param->getNewWriter());
    }
Logged
linuxanton
Junior Member
**

Karma: 0
Offline Offline

Posts: 9


View Profile
« Reply #3 on: Mar. 16, 2009, 07:39:11 PM »

Hi,

I have a solution for my problem. It's a little tricky and dirty, but it works.

Here it is:

in tabpanel.js you have to replace

Code:
Event.observe(element, "click", this.elementClicked.bindEvent(this,item));
                             


with

Code:
Event.observe(element, "click", this.elementClicked.bindEvent(this,item));
Event.observe(element, "foo:bar", this.elementClicked.bindEvent(this,item));

and the ImageButton or what else looks like

Code:
<com:TLabel Text="Click" Attributes.onClick="$('<%# $this->TabView->getClientID() '%>').fire('foo:bar');" />


It works ...

Anton
Logged
natsimhan
Senior Member
***

Karma: 9
Offline Offline

Posts: 350



View Profile WWW
« Reply #4 on: May. 12, 2009, 04:33:59 AM »

Hi,

I had the same problem... and I found a better solution, whithout change in prado's framework's files.

You must use the capability of Prado.Element to send click event like this :

Code:
Prado.Element.click('ctl0_Content_MyTabView_0');

The difficult was this $this->MyTabView->getClientID() return ctl0_Content_MyTabView and not ctl0_Content_MyTabView_0, because the _0 is added by JS script client.

So, you must add it manually...

In Javascript in your page :
Code:
Prado.Element.click(<%=$this->MyTabView->getClientID().'_0'%>);

Or from a callback's function in your PHP class :
Code:
$this->getCallbackClient()->click($this->MyTabView->getClientID().'_0');

It works for me under Prado 3.1.4 but I suppose that it works since 3.1.1

Hope this help someone...
Logged

Visitez le petit monde de Natsimhan, pleins d'articles sur Prado, PHP, MySQL, les anti-bots...
Pages: [1] Print 
« previous next »
Jump to: