Yii Framework Forum: How To Get Data From Specified Row In Cgridview? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Get Data From Specified Row In Cgridview? Rate Topic: **--- 1 Votes

#1 User is offline   nakovn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 18-July 12

Posted 08 October 2012 - 08:53 PM

Please help me!
This is my code:
$this->widget('zii.widgets.grid.CGridView', array(
            'id'           => 'employee-grid',
            'dataProvider' => $em,
            'columns'      => $attribute,
            'filter'       => $em->model,
            'selectableRows'=> 1,
            'selectionChanged'=>'function(id){
                var ids = $.fn.yiiGridView.getSelection(id);
                $("#MHRRewardEmployee_employee_id").val(ids);
            }',
        ));

Attached File(s)


0

#2 User is offline   oxigen 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 05-February 09

Posted 08 October 2012 - 09:37 PM

View Postnakovn, on 08 October 2012 - 08:53 PM, said:

Please help me!
This is my code:
$this->widget('zii.widgets.grid.CGridView', array(
            'id'       	=> 'employee-grid',
            'dataProvider' => $em,
            'columns'      => $attribute,
            'filter'   	=> $em->model,
            'selectableRows'=> 1,
            'selectionChanged'=>'function(id){
                var ids = $.fn.yiiGridView.getSelection(id);
                $("#MHRRewardEmployee_employee_id").val(ids);
            }',
        ));


use js found id, then ajax request to get row details update for form
0

#3 User is offline   nakovn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 18-July 12

Posted 08 October 2012 - 09:52 PM

Thanks @oxigen for reply!
I'm a newbie, and i don't know how to get data from selected row to update the textField.
Can you help me?
0

#4 User is offline   oxigen 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 05-February 09

Posted 10 October 2012 - 10:54 PM

Try follow code:

Yii::app()->clientScript->registerScript('UpdateForm', "
$('body').delegate('#employee-grid tbody > tr','click',function(){
    var id = $.fn.yiiGridView.getKey('employee-grid', $('#employee-grid tbody > tr').index(this));
    //request ajax update form
    $.getJSON('/path/to/get/details', {id:id}, function(data){
        //TODO: update form data
    });
});
");

$this->widget('zii.widgets.grid.CGridView', array(
            'id'   		=> 'employee-grid',
            'dataProvider' => $em,
            'columns'      => $attribute,
            'filter'   	=> $em->model,
        ));

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users