Yii Framework Forum: How To Sort A Complicated Column ('value'=>Array($This, 'myfunc')) In Yii Cgridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Sort A Complicated Column ('value'=>Array($This, 'myfunc')) In Yii Cgridview Rate Topic: -----

#1 User is offline   Ganiks 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-September 13
  • Location:ShangHai,China

Posted 09 September 2013 - 04:14 AM

my view:
 11     'columns'=>array(
  3             array('name'=>'count',
  2                 'headerHtmlOptions'=>array('width'=>'100px'),
  1                 'value'=>array($this, 'getCount'),
  0                 'header'=>'商家数量',                                                                                                                                               
  1                 'type'=>'raw',
  2                 'sortable'=>true,
  3             ),


my controller:


  0     public function getCount($data, $row, $c)                                                                                                                                       
  1     {
  2         return $this->actionSourceMoreIDARRAY[$data['id']];
  3     }


from the classBook I know that:
$sortable property ---
Defaults to true. Note that if name is not set, or if name is not allowed by CSort, this property will be treated as false.

Of course , my column's value is from a function ..

anyone give me a solution? thanks a lot .

This post has been edited by phpgcs: 09 September 2013 - 04:19 AM

0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,045
  • Joined: 16-February 11
  • Location:Japan

Posted 09 September 2013 - 07:24 AM

Hi phpgcs,

When working with CActiveDataProvider or CSqlDataProvider, the sorting is (and must be) executed on the SQL level. So if you are getting 'count' by a php function, you can not sort by it.

Ah, welcome to the forum, BTW. :)
0

#3 User is offline   Ganiks 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-September 13
  • Location:ShangHai,China

Posted 09 September 2013 - 08:12 PM

View Postsoftark, on 09 September 2013 - 07:24 AM, said:

Hi phpgcs,

When working with CActiveDataProvider or CSqlDataProvider, the sorting is (and must be) executed on the SQL level. So if you are getting 'count' by a php function, you can not sort by it.

Ah, welcome to the forum, BTW. :)


thanks a million for your reply , you remind me to know more about the working principle of yii frame .. thanks again. :rolleyes:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users