Yii助推器向导表格小部件内容

时间:2014-02-10 09:37:52

标签: yii frameworks widget yii-booster

我试图将yiibooster向导形式的内容放入一个小部件,但我无法使其工作。客户的想法是逐步形成,在每个内容中选择一些数据。

小部件是这样的:

$this->widget(
'bootstrap.widgets.TbWizard',
array(
    'type' => 'tabs', // 'tabs' or 'pills'
    'pagerContent' => '<div style="float:right">
                <input type="button" class="btn button-next" name="next" value="Siguiente" />
            </div>
            <div style="float:left">
                <input type="button" class="btn button-previous" name="previous" value="Atrás" />
            </div>
            <br /><br />',
    'options' => array(
        'nextSelector' => '.button-next',
        'previousSelector' => '.button-previous',
        'onTabShow' => 'js:function(tab, navigation, index) {
                    var $total = navigation.find("li").length;
                    var $current = index+1;
                    var $percent = ($current/$total) * 100;
                    $("#wizard-bar > .bar").css({width:$percent+"%"});
        }',
        'onTabClick' => 'js:function(tab, navigation, index) {alert("Tab Click Disabled");return false;}',
    ),
    'tabs' => array(
        array(
            'label' => 'Arrendatarios',
            'content' => 'Home Content',
            'active' => true
        ),
        array('label' => 'Inmuebles', 'content' => 'Profile Content'),
        array('label' => 'Fecha', 'content' => 'Messages Content'),
    ),
)

);

我想在每个“内容”标签中输入以下内容:

$this->widget('bootstrap.widgets.TbGridView',
            array(
            'id'=>'arrendatario',
            'selectableRows'=>1,
            'selectionChanged'=>'obtenerArrendatario',
            'type'=>'striped bordered condensed',
            'dataProvider'=>$arrendatarios->search(),
                'filter' => $arrendatarios,
            'template'=>"{items}\n{pager}",
            'columns'=>array(       
                array('name'=>'arrendatario_id_personal', 'header'=>'DNI',),
                array('name'=>'arrendatario_nombre', 'header'=>'Nombre'),
                array('name'=>'arrendatario_email', 'header'=>'Email'),   
            ),
        ));

任何人都可以帮助我吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

是的,你可以这样做。
 首先制作包含Cgridview或您想要的任何内容的视图。例如,你已经制作了3个名为_form_basic,_form_location,_form_officialUse的视图文件。现在您可以按照下面的说明渲染它们。

 $this->widget('bootstrap.widgets.TbWizard', array(
    'type' => 'pills', // 'tabs' or 'pills'
            'options' => array(
                    //'onTabShow' => 'js:function(tab, navigation, index) { if((index+1) > 1) {alert("Tab #" + (index+1));} }',
                    'onTabClick' => 'js:function(tab, navigation, index) {return false;}',
            ),
            'tabs' => array(
                array('label' => 'Basic Information', 'content' => $this->renderPartial('pages/_form_basic', array('model' => $model, 'form' => $form), true), 'active' => true),
                array('label' => 'Residential Information', 'content' => $this->renderPartial('pages/_form_location', array('model' => $model, 'form' => $form), true)),
                array('label' => 'Official Information', 'content' => $this->renderPartial('pages/_form_officialUse', array('model' => $model, 'form' => $form), true)),
            ),
        )
        );

在CgridView或其他任何你想要的页面中做任何你想要的事情。