I have some obvious questions about CGridView. Even if I tried, I wasn’t able to find answers to them myself. Maybe someone find some time to help me as I’m lost here!
I’ve implemented mdobma’s solution with Reset button described here. But when I changed CGridView not to display filters at all, it again stopped working. I.e. Form fields are being cleaned, CGridView is being refreshed but it does not reflect changes (no, filters - revert to showing all records). I have to click Search after clicking Reset to really reset CGridView. Can’t understand why it doesn’t work - if form fields are cleaned and then CGridView receives update request?
I’ve modified my CGridView to respect filters with following code described in this post:
$criteria = new CDbCriteria; $criteria->compare('DATR', $model->DATR, true); $criteria->compare('BCODE', $model->BCODE, true); $criteria->compare('PATIENT', $model->PATIENT, true); $criteria->compare('PESEL', $model->PESEL, true); $criteria->compare('UDATE', $model->UDATE, true); $criteria->select = 'ID, STAT, DATR, BCODE, PATIENT, PESEL, UDATE'; $criteria->order = 'DATR DESC'; $dataProvider = new CActiveDataProvider($model, array ( 'criteria'=>$criteria, 'pagination'=>array('pageSize'=>20), ));
It seems to be half-working. For example - there are problems with case sensitivity. If I enter data lowercase and grid view contains it uppercase, it does not work.
$criteria->compare('PATIENT', $model->PATIENT, true);
$criteria->compare('PATIENT', strtoupper($model->PATIENT), true);
also does not solve problem. If I don’t enter data in uppercase, it will not be searched (filtered) - since data is uppercased in DB. Is it a normal behaviour?
What is the best way to search empty columns? Right now if I enter empty value to search form field, filtering for that particullar column is ignored, if I’m not mistaken.
How can I use CDbCriteria->compare (or any other CDbCriteria method) to have more complex searching ./ filtering? I.e. If I want to filter field (column) having date for being in some range?
Thanks in advance for any help here. Cheers!