Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Code below - it's only example, main principles of solution. First principle: we don't need refresh page (by the submit), we need only refresh CGridView after request.</p> <h2>The solution has a few parts:</h2> <ol> <li><p>We need form with some parameters. In your case - <em>fromDate</em> and <em>toDate</em>. You have this one already. But we don't need any submit element. At all! We will use AJAX.</p></li> <li><p>We need some function for initiate AJAX-request. For example, let's event for this request will be <strong>change</strong> of parameters *from_date* or *to_date*. This function also must update CGridView after request. </p></li> <li><p>We need action in controller for processing AJAX-request.</p></li> </ol> <h2>Let's begin from part 2. It may be some like this:</h2> <blockquote> <pre><code>Yii::app()-&gt;clientScript-&gt;registerScript('scriptId', "var ajaxUpdateTimeout; var ajaxRequest; $('**selector_for_parameters_fields**').change(function(){ ajaxRequest = $(this).serialize(); clearTimeout(ajaxUpdateTimeout); ajaxUpdateTimeout = setTimeout(function () { $.fn.yiiGridView.update( // this is the id of the CGridView 'acc-payment-recei-grid', {data: ajaxRequest} ) }, // this is the delay 300); });" ); </code></pre> </blockquote> <p>Place this code into view. Notes:</p> <p><code>$(this).serialize()</code> - key moment. Look for <a href="http://api.jquery.com/serialize/" rel="nofollow">more info</a></p> <p><code>selector_for_parameters_fields</code> - give them ( <em>fromDate</em> and <em>toDate</em> ) some unique selector</p> <p>We use some <code>delay</code> (300 ms) for decreasing loading from unnecessary AJAX-requests</p> <h2>Now - about action in Controller</h2> <blockquote> <pre><code>public function actionIndex($fromDate='', $toDate='') { $criteria = new CDbCriteria(); if(!empty($fromDate)) $criteria-&gt;addSearchCondition('your search condition about fromDate'); if(!empty($toDate)) $criteria-&gt;addSearchCondition('your search condition about toDate'); $dataProvider=new CActiveDataProvider('YourModel', array('criteria' =&gt; $criteria,)); $this-&gt;render('YourView',array('dataProvider'=&gt;$dataProvider,)); } </code></pre> </blockquote> <p>It must works, but requires some tuning for concrete conditions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload