Yii Framework Forum: Checkbox Gridview Dan Form - Yii Framework Forum

Jump to content

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

Checkbox Gridview Dan Form Rate Topic: -----

#1 User is offline   arief 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 03-August 09

Posted 23 February 2013 - 02:12 AM

dear agan,

saya ada kendala bagaimana memasukkan id dari gridview yg dipilih ke hidden text form yang ada
saya ingin ketika ajax button select customer di klik, id customer masuk ke hidden text form create yang saya buat.

view create:
...
<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'customer-grid',
    'dataProvider'=>$customer->showCustomer(),
    'filter'=>$customer,
    'columns'=>array(
      array(
       'class'=>'CCheckBoxColumn',
       'id'=>'id',
       ),
      'id',
      'name',
      'identity_no',
      'city',
      'customer_type',
    ),
));
?>
<?php
  echo CHtml::ajaxButton('Select Customer', CController::createUrl('selectCustomer'), array(
      'type'=>'POST',
      'data'=>'js:{customer_id : $.fn.yiiGridView.getChecked("customer-grid","id").toString()}',
    )
  );
?>
<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>
...


view form:
...
<div class="row">
    <?php echo $form->hiddenField($model,'customer_id',array('size'=>10,'maxlength'=>10)); ?>
</div>
...


controller:
...
public function actionSelectCustomer()
  {
    if(isset($_POST['customer_id']))
    {
      $customer_id=$_POST['customer_id'];
    }
  }
...


thanks atas pencerahannya :)
0

#2 User is offline   C.S.Putera 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 18-May 11

Posted 25 February 2013 - 09:22 AM

Hello agan. Ane belum pernah pake yang persis kayak gitu sih, tapi mirip2, hehehe.

Bisa dicoba seperti ni :

echo CHtml::ajaxButton('Select Customer', CController::createUrl('selectCustomer'), array(
      'type'=>'POST',
      'data'=>'js:{customer_id : $.fn.yiiGridView.getChecked("customer-grid","id").toString()}',
      'sucess'=> 'function(data){
			$("#Customer_customer_id").html(data);
	          }',
    )
  );


Di controllernya :

...
public function actionSelectCustomer()
{
    if(isset($_POST['customer_id']))
    {
      $customer_id=$_POST['customer_id'];
      echo $customer_id;
      Yii::app()->end(); 
    }
}
...


Seharusnya bisa spt itu selama yang dipilih cuma 1 Customer, hehe. Selamat mencoba :D
0

#3 User is offline   arief 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 03-August 09

Posted 26 February 2013 - 04:46 AM

View PostC.S.Putera, on 25 February 2013 - 09:22 AM, said:

Hello agan. Ane belum pernah pake yang persis kayak gitu sih, tapi mirip2, hehehe.

Bisa dicoba seperti ni :

echo CHtml::ajaxButton('Select Customer', CController::createUrl('selectCustomer'), array(
      'type'=>'POST',
      'data'=>'js:{customer_id : $.fn.yiiGridView.getChecked("customer-grid","id").toString()}',
      'sucess'=> 'function(data){
			$("#Customer_customer_id").html(data);
	          }',
    )
  );


Di controllernya :

...
public function actionSelectCustomer()
{
    if(isset($_POST['customer_id']))
    {
      $customer_id=$_POST['customer_id'];
      echo $customer_id;
      Yii::app()->end(); 
    }
}
...


Seharusnya bisa spt itu selama yang dipilih cuma 1 Customer, hehe. Selamat mencoba :D


thanks gan atas respon & solusinya :)

berawal dari kasus ane diatas, memungkinkan ngga gan memilih 2 item data dari 2 gridview yang berbeda
bisakah dimasukkan dalam 1 array (dieksekusi dg 1 ajaxbutton)
0

#4 User is offline   C.S.Putera 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 18-May 11

Posted 26 February 2013 - 08:16 PM

Mungkin bisa dicoba seperti ini gan :

echo CHtml::ajaxButton('Select Customer', CController::createUrl('selectCustomer'), array(
      'type'=>'POST',
      'data'=>'js:{customer_id : $.fn.yiiGridView.getChecked("customer-grid","id").toString()},
                  {cs_group_id : $.fn.yiiGridView.getChecked("customer-group","id").toString()}',
      'sucess'=> 'function(data){
                        $("#Customer_customer_id").html(data);
                  }',
    )
  );


So ditambahin variable yang dikirimnya, tapi masih bukan array sih, hehehe. Lalu di controllernya :

...
public function actionSelectCustomer()
{
    if(isset($_POST['customer_id']) && isset($_POST['cs_group_id ']))
    {
         $customer_id=$_POST['customer_id'];
         $cs_group_id=$_POST['cs_group_id '];
         echo $customer_id;
         Yii::app()->end(); 
    }
}
...


Kalau menurut ane spt itu sih gan, hehehe...
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