ajaxlink in cgridview

Hi YII Master,

I need a help about cgridview, I wanna make a button/link(postPone) in cgridview, and it will make a pop-up(something like CJUiDialog) containing 2 field (date and reason),and then will automatically update the data after save…

please advice, and give me some more example…

thanks

Kodok,

About a dialog and form, take a look here

Thanks Zaccaria, but I need more info regarding how to call CJuiDialog from CGridView, and pass the value from CGridView to CJuiDialog

You can use a CDataColumn, set the type to raw in order to save the html and give as value the code in the wiki.

Create a subview for button+cgridview, and pass to the subview the model.




// configuring CGridView button column...

'columns'=>array(

    array(

        'class'=>'CButtonColumn',

        'template'=>'{my_button} {view} {update} {delete}',

        'buttons'=>array(

            'my_button'=>array(

                'label'=>'My Button Label',

                'url'=>'...some url (php expression)...',

                'imageUrl'=>'...image url...',

                'options'=>array(

                    'ajax'=>array(

                        'type'=>'GET',

                        'url'=>"js:$(this).attr('href')",

                        'success'=>'js:function(data){$("#dialog-id").dialog("open");}',

                    ),

                ),

            ),

        ),

    ),

),


// dialog widget

$this->beginWidget('zii.widgets.jui.CJuiDialog', array(

    'id'=>'dialog-id',

    'options'=>array(

        'title'=>'Dialog title',

        'autoOpen'=>false,

        'width'=>800,

    ),

));

// dialog content here...

$this->endWidget();



Inside a dialog you’ll need to create an CHtml::ajaxLink() or CHtml::ajaxSubmitButton(), which will send data to some controller/action and then update a grid:




$.fn.yiiGridView.update("grid-id");



It’s just an idea, but not a working example, but I hope it helps ;)