I have a view having a single CHTML text field and a TbExtendedGridView. Selected rows from the tbExtendedGridView along with the text field data are to be submitted to the database. It is a batch addition process where each row along with the textfield data is one record.
I can get the selected rows using the js function js:{chk:$.fn.yiiGridView.getSelection(‘gridname’)}. How can I pass the textfield data along with the selected row data in the CHTML submit button.
View File:
<div class="form">
<?php $form=$this->beginWidget(‘CActiveForm’, array(
'id'=>'client-account-create-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'formname'); ?>
<?php echo $form->textField($model,'formname'); ?>
<?php echo $form->error($model,'formname'); ?>
</div>
<div class="row">
<?php
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'type'=>'striped bordered condensed',
'id'=>'grsubfielddata',
'fixedHeader' => true,
'headerOffset' => 40,
'dataProvider' => new CActiveDataProvider('Subfields',array(
'criteria'=>array(
'order'=>'tagno, slno',),
'pagination'=>array('PageSize'=>20,), )),
'enablePagination' => TRUE,
'selectableRows'=>2,
'pager' => array(
'cssFile' => false,
'header' => false,
'firstPageLabel' => 'First',
'prevPageLabel' => 'Previous',
'nextPageLabel' => 'Next',
'lastPageLabel' => 'Last',),
'template'=>"{pager}\n{items}\n{pager}",
'columns' => array(
array(
'class'=>'CCheckBoxColumn',
'id'=>'chk',
),
'tagno','fieldcode','fieldname'),
));
?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('orgSubmit', array("data" => "js:{chk:$.fn.yiiGridView.getSelection('grsubfielddata')}")); ?>
</div>
<div>
</div>
<?php $this->endWidget();?>
</div><!-- form -->