title: Yii CGridview Filter Datepicker
body: <p>I have already read the forum about make custom cgridview.. I want to make filter use datetimepicker.</p>
  
  <p>Datetimepicker:</p>
  
  <p>I can include already the datetimepicker, but when I choose the date, it became error. :(.. 
  My date datatype on database is 'timestamp'
  <img src="https://i.stack.imgur.com/ed9w0.jpg" alt="Date">
  <img src="https://i.stack.imgur.com/N3Fge.jpg" alt="Error"></p>
  
  <p>This is the code</p>
  
  <pre><code>&lt;?php
  $this-&gt;breadcrumbs=array(
      'Events'=&gt;array('index'),
      'Manage',
  );
  
  $this-&gt;menu=array(
      array('label'=&gt;'List Event','url'=&gt;array('index')),
      array('label'=&gt;'Create Event','url'=&gt;array('create')),
  );
  
  Yii::app()-&gt;clientScript-&gt;registerScript('search', "
  $('.search-button').click(function(){
      $('.search-form').toggle();
      return false;
  });
  $('.search-form form').submit(function(){
      $.fn.yiiGridView.update('event-grid', {
          data: $(this).serialize()
      });
      return false;
  });
  ");
  ?&gt;
  
  &lt;h1&gt;Manage Events&lt;/h1&gt;
  
  &lt;p&gt;
  You may optionally enter a comparison operator (&lt;b&gt;&amp;lt;&lt;/b&gt;, &lt;b&gt;&amp;lt;=&lt;/b&gt;, &lt;b&gt;&amp;gt;&lt;/b&gt;, &lt;b&gt;&amp;gt;=&lt;/b&gt;, &lt;b&gt;&amp;lt;&amp;gt;&lt;/b&gt;
  or &lt;b&gt;=&lt;/b&gt;) at the beginning of each of your search values to specify how the comparison should be done.
  &lt;/p&gt;
  
  &lt;?php echo CHtml::link('Advanced Search','#',array('class'=&gt;'search-button btn')); ?&gt;
  &lt;div class="search-form" style="display:none"&gt;
  &lt;?php $this-&gt;renderPartial('_search',array(
      'model'=&gt;$model,
  )); ?&gt;
  &lt;/div&gt;&lt;!-- search-form --&gt;
  
  &lt;?php $this-&gt;widget('bootstrap.widgets.TbGridView',array(
      'id'=&gt;'event-grid',
      'dataProvider'=&gt;$model-&gt;search(),
      'filter'=&gt;$model,
      'afterAjaxUpdate'=&gt;"function(){jQuery('#event_date_search').datepicker({'dateFormat': 'yy-mm-dd'})}",
      'columns'=&gt;array(
          array(
              'type' =&gt; 'raw',
              'name'=&gt; 'event_image',
              'value' =&gt; 'CHtml::image("'.Yii::app()-&gt;request-&gt;baseUrl.'/uploads/event/$data-&gt;event_image", "event_image" ,array("width"=&gt;100))',
              'filter'=&gt; false,
          ),
          'event_name',
          array(
              'name' =&gt; 'event_date',
              'type' =&gt; 'raw',
              'filter'=&gt;$this-&gt;widget('zii.widgets.jui.CJuiDatepicker', array(
                  'model'=&gt;$model,
                  'attribute'=&gt;'event_date',
                  'htmlOptions' =&gt; array(
                      'id' =&gt; 'event_date_search'
                  ), 
                  'options' =&gt; array(
                      'dateFormat' =&gt; 'yy-mm-dd'
                  )
              ), true)
          ),
          array(
              'name'=&gt;'published',
              'filter'=&gt;CHtml::dropDownList('Event[published]', '',  
                  array(
                      ''=&gt;'',
                      '1'=&gt;'Published',
                      '0'=&gt;'Not Published',
                  )
              ),
              'value' =&gt;'($data-&gt;published==1)?"Published":"Not Published"',
          ),
          array(
              'class'=&gt;'bootstrap.widgets.TbButtonColumn',
          ),
      ),
  )); 
  
  ?&gt;
  </code></pre>
  
  <p>Thank you very much...</p>