Hey Guys, Does anyone have any idea why my virtual attributes is not appearing in my search() model when i sort column using DataTable extension,
I have already declared the virtual attribute as public in the model, set the virtual attribute as safe and also set the attributes in
$dataProvider = new CActiveDataProvider($this, array(
'criteria' => $criteria,
'sort' => array('attributes' => array('statusRole' => array('asc' => "statusRole",'desc' => "statusRole DESC"))),
));
when i sort the column using the virtual attribute ‘statusRole’, it doesnot set the order “statusRole” as ASC or DESC, which means that the attributes is not set.
My Virtual attribute is calculated like below in my select criteria:
$criteria->select = 't.*, CASE WHEN (t.type = “Ad” AND (t.period =“new”)
AND period.start_date <= NOW())
THEN "open"
WHEN (t.type = "DE" AND t.period = "latter" AND period.start_date <= NOW())
THEN "open"
ELSE "closed" END as statusRole'
Note i have also tried using Csort but it dint work.
Can someone pull out the genius solution for this?