Hello,
I’m trying to develop a dialog form to filter dates by a “From” and “To” in my CGridView. The eventual goal would be to eliminate the search form and just use the table filters. I’m in the process of testing my dialog but can’t seem to pass my date value to the search function. The CGrid gets updated but my date value doesn’t get applied. Can you tell what I’m doing wrong?
FORM
<div class="dialogtest" style=display:none><form style="font-size:1em;">
From <input type='text' maxlength='16' id='fromdate' name='fromdate'></input></form></div>
JQuery
Yii::app()->clientScript->registerScript("test",
"
$('input[name*=date]').dblclick(function(){
var posLeft=$(this).position().left;
var posTop=$(this).position().top;
$('.dialogtest').dialog({autoOpen: false,
position:[posLeft,posTop],
buttons:{
'OK':function(){
//alert($('#fromdate').serialize());
$.fn.yiiGridView.update('timeentries-grid',{data: $('#fromdate').serialize()});
$(this).dialog('close');
}
}
});
$('.dialogtest').dialog('open');
});
$('#fromdate').click().datepicker({
disable:false,
numberOfMonths: 1,
showButtonPanel: true,
dateFormat: 'yy-mm-dd'
});
"
, CClientScript::POS_READY);
Model
public $fromdate;
public function rules()
{
array('time, date,fromdate, project, internalid, notes, projectitem, timerunning, createdby, createddate, updatedby, updateddate', 'safe', 'on'=>'search'),
}
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('time',$this->time,true);
$criteria->compare('date',$this->fromdate,true,'>=');
$criteria->compare('project',$this->project,true);
$criteria->compare('internalid',$this->internalid,true);
$criteria->compare('notes',$this->notes,true);
$criteria->compare('projectitem',$this->projectitem,true);
$criteria->compare('timerunning',$this->timerunning);
$criteria->compare('createdby',$this->createdby,true);
$criteria->compare('createddate',$this->createddate,true);
$criteria->compare('updatedby',$this->updatedby,true);
$criteria->compare('updateddate',$this->updateddate,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>array('pagesize'=>40),
));
}