Hi guys,
I’d like to add an event to a Grid Column so when that cell is clicked, it creates an input box to edit. Then when leave, the data is sent through a post/ get / action that saves that data with its ID to its table.
My current challenge is to send and receive the data. I did some code as follows.
$this->widget('application.extensions.CEditableGridView.CEditableGridView',array(
//$this->widget('bootstrap.widgets.TbGridView', array(
'id'=>'temp-mr-grid',
'showQuickBar'=>'false',
'quickUpdateAction'=>'QuickUpdate',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
// 'MCustomerSuffix',
// 'BillingGroupID',
// 'BillingMonth',
'id',
'CustomerID',
// 'Reading' => array('type' =>'application.extensions.ds.jeditable.DsJEditableWidget', 'jeditable_type' => 'text')
array('header' => 'Reading', 'name' => 'Reading', 'class' => 'application.extensions.CEditableGridView.CEditableColumn'),
// Reading
/* array('name'=>'Reading',
'value' => 'CHtml::link($data->Reading, Yii::app()
->createUrl("mreading/update",array("id"=>$data->id)))',
'type' => 'raw',
),
/* 'MeterReaderID',
'MeterReaderID' => array(
'type'=>'html',
'value' => '$data->MeterReaderID?"<a class=\'editable-".$data->id."\'> </a>"',
'header' => ' Reader'
),
/* 'Reading' => array(
'type'=>'html',
'value' => '$data->Reading?"<a class=\'editable-".$data->id."\'></a>"',
'header' => 'Reading'
), */
/*
'DateOfReading',
'Reading',
'ReadingCode',
'ReadingComments',
'ConsumptionComments',
'ReadingQIndicator',
'ControlIndicator',
'CalcConsumption',
'ConsumptionQuality',
'AvgConsumption',
'ConsumptionForBilling',
'BaseofBilling',
'LastUpdateDate',
'LastUpdateUser',
'Variance',
'PreviousCalcConsumption',
'PreviousReading',
'MeterNo',
'GeoLocation1ID',
*/
array(
'class'=>'CButtonColumn',
'template'=>'',
),
),
));
the action quckUpdate has two arguments ($row and $data), row is the ID of the Cell and data is the variable that holds the cell data. as follows.
public function quickUpdate($row,$data){
// $model=new TempMr;
if(isset($_POST['id']) && isset($_POST['Reading']))
{
Yii::app()->db->createCommand("UPDATE temp_mr SET Reading='".$_POST['Reading']."' WHERE id ='".$_POST['id']."' ")->execute();
// $model->attributes=$_POST['Model'];
/* if($model->save())
$this->redirect(array('admin')); */
}
}
When I check my dev tools console, no data is passed. Any help please I would Finnish this app.