Instructions for QTabs in Qcubed2?

Login or register to post comments
10 replies [Last post]
cliff's picture
Offline
Joined: 04/11/2008

I see the QTabs class that wraps the jqueryUI tabs element, but I can't see any examples on how it is supposed to be used. Any ideas?

Offline
Joined: 03/31/2008
Offline
Joined: 03/31/2008

No, QTabPanel is an unrelated plugin.

cliff's picture
Offline
Joined: 04/11/2008

QTabs are another one of those auto-generated stubs from the jqueryUI docs. I was able to hack something and make it work, but it needs to be fixed. I'll spend a little time next week to see if I can knock something up.

vakopian's picture
Offline
Joined: 04/08/2008

Cliff,

There is an example for QTabs in assets/_core/php/examples/other_controls/jq_example.php.
Here is the example code:

<?php
$this
->Tabs = new QTabs($this);
$tab1 = new QPanel($this->Tabs);
$tab1->Text = 'First tab is active by default';
$tab2 = new QPanel($this->Tabs);
$tab2->Text = 'Tab 2';
$tab3 = new QPanel($this->Tabs);
$tab3->Text = 'Tab 3';
$this->Tabs->Headers = array('One', 'Two', 'Three');
?>

QTabs considers every immediate child control a tab content/section (and it wraps them into a div), so typically you would use QPanels as the only immediate children for QTabs. The header for each tab can be a simple string as in the example above, or can be any QControl. You can either use the Headers property to set all the headers at once (as in the example) or the SetHeader() method, to set each header separately.

Let me know if you need anything more complex and I'll try to given an example for your use case.

-Vartan

vakopian's picture
Offline
Joined: 04/08/2008

Forgot to say, that this is not in 2.0.1, but is currently in trunk, and will be in 2.0.2 very soon.

Offline
Joined: 04/01/2008

Can QTabs take content other then just text? Like is there a way to put other QControls into the tabs?

Thanks!

Steven Warren's picture
Offline
Joined: 11/06/2008

QTabs are QPanels so you can treat them just as you would any other QPanel. You would basically make the QControls parent the QTab and either set the QTabs AutoRenderChildren attribute to true, or create a template file for the QTab.

Take a look at the QPanel example and you will see how it is done.
QPanel Example

Offline
Joined: 03/31/2008

I have existing QPanel classes. They work just fine on their own.
I want to display them on different QTabs.

I figured I would instantiate them like this:

<?php
            $this
->Tabs = new QTabs($this);
           
$tab1 = new MyQPanelCustomClass1($this->Tabs);
           
$tab2 = new MyQPanelCustomClass2($this->Tabs);
           
$this->Tabs->Headers = array('One', 'Two');
?>

This is not working.( I am getting error about arguments)
I am using panels generated by QCubed with Meta Datagrid on them. I believe my issue is coming with the fact that the constructor for these two classes has 4 parameters and I am only passing "$this->Tabs" as a parameter. What should the other parameters be defaulted to and how do I instantiate them?

Any example to help will be very much appreciated.
Thanks!

Steven Warren's picture
Offline
Joined: 11/06/2008

Constructor for the generated List Panel drafts looks like this

public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null)

You need to pass the name of your SetEditPanel and CloseEditPanel functions.

If you look at the "/assets/_core/php/_devtools/panel_drafts.php" file in your installation you can get an idea of how it works.

Offline
Joined: 03/31/2008

Thanks Steven!