tel8618217223380 / prado3

Automatically exported from code.google.com/p/prado3
Other
0 stars 0 forks source link

ActiveControls's Visible property should be reflected clientside on ajax requests #372

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
hi!

i fail to toggle two tactivepanels:
v is hidden -> e is visible vs.
v is visible -> e is hidden

unfortunately, the following code does not work (neither with 3.1.10 nor with 
the current trunk).

if i switch from TActiveButton to TButton, everything works as expected.

moreover, if i start with both panels visible and then start toggling, it works 
as well.

but if one panale has Visible="false" from the beginning, this panel will never 
appear on the screen.

i tried:
1. changing OnClick to OnCallback
2. using $this->v->render(...)
3. shuffling the two panels
4. setting the visibility during onInit() or onLoad()

nothing workd - any ideas on what i'm doing wrong?

thanks,
raoul

P.page:
-- cut--
<com:TForm>
    <com:TActivePanel Id="v" Visible="false">
        view
    </com:TActivePanel>
    <com:TActivePanel Id="e" Visible="true">
        edit
    </com:TActivePanel>
    <com:TActiveButton Text="toggle" OnClick="toggle" />
</com:TForm>

-- cut--

P.php:
-- cut--
<?php

Prado::using('System.Web.UI.ActiveControls.*');

class P extends TPage
{
    public function toggle($sender, $param)
    {  
        if ($this->v->Visible == true) {
            $this->v->Visible = false;
            $this->e->Visible = true;
        } else {
            $this->v->Visible = true;
            $this->e->Visible = false;
        }
    }
}
-- cut--

Original issue reported on code.google.com by ra...@bhatia.at on 9 Nov 2011 at 5:01

GoogleCodeExporter commented 9 years ago
Unfortunately that's not the way TActivePanel works..  TActivePanel's 
documentation states: "TActivePanel allows the client-side panel contents to be 
updated during a callback response using the render method.".
The "Visible" property of a TActivePanel is not part of its contents, so it 
won't be updated.
In reality, the TActivePanel::Visible is not even something that can be changed 
clientside, since it's not an attribute of the <div> representing the 
TActivePanel.
Other things could work:
1) setStyle("display:none") on the TActivePanel will hide it from the user (but 
the panel will still be present in the html code with its subcontrols);
2) insert a TPanel inside the TActivePanel, call TPanel->setVisible(false) and 
then TActivePanel->render(...);

We could find a way to make TActivePanel work like you want it, but then it 
should work not only for TActivePanel, but also for all the others 
ActiveControls.

Original comment by ctrlal...@gmail.com on 9 Nov 2011 at 11:18

GoogleCodeExporter commented 9 years ago
imho, this (setting visible = true shows the control on the website) would be 
the expected behavior. can we file a feature request for that?

thanks,

Original comment by ra...@bhatia.at on 15 Nov 2011 at 10:08

GoogleCodeExporter commented 9 years ago
It's definitely a nice feature request, reopening the ticket re-targeting it

Original comment by ctrlal...@gmail.com on 15 Nov 2011 at 11:06

GoogleCodeExporter commented 9 years ago
i've committed a dirty but working test patch in r3064. I'm open for comments

Original comment by ctrlal...@gmail.com on 15 Nov 2011 at 5:33

GoogleCodeExporter commented 9 years ago

Original comment by ctrlal...@gmail.com on 18 Jan 2012 at 9:37