0

I want to update CGridview Date column on clicking the CJuiDatePicker's Date.

CJuiDatePicker Code:

<?php
 $this->widget('zii.widgets.jui.CJuiDatePicker',
    array(
        'id'=>'date-picker-id',
        'model' => Holidays::model(),
        'attribute' => 'date',
        'flat' => true,  
        'options'=>array(
        'onSelect'=>'js: function(dateText) {
        $("#schedules-grid").yiiGridView("update", {        
            data: "date="+dateText, 
        });
        }'
    ),
    )

); ?>

My grid code:

 <?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'schedules-grid',
    'dataProvider'=>Holidays::model()->search(),
    'columns'=>array(       
       'seq',
    array(
         'name' => 'name',
           'value' =>'"holiday"',
            'type' => 'raw',
         ),
     'date',    
         array(
            'name'=>'is_active',         
            'value' =>'"Y"',
        ),      
    ),
)); ?>

Im getting seleted date in "dateText" variable how to update that value in the grid's Date Column ????

shgnInc
  • 2,054
  • 1
  • 23
  • 34
Ayyanar G
  • 1,545
  • 1
  • 11
  • 24

1 Answers1

0

using this to update yiiGridView $.fn.yiiGridView.update("schedules-grid")

'onSelect'=>'js: function(dateText) {
             $.fn.yiiGridView.update("schedules-grid",
               {data: "date="+dateText,
             });`
chen
  • 407
  • 2
  • 9
  • In your DB how to store the date? – chen Jan 21 '14 at 07:33
  • on selecting cjuidatepicker itself i want to save the "date" in db,im newbie to yii can you explain how to do this??? – Ayyanar G Jan 21 '14 at 08:56
  • data pass the "date" to php is use the url. So you need using $_GET["date"] not $_POST["date"]. and about how to save the "date" to DB. I believe you already know how to do it. – chen Jan 21 '14 at 09:28