Yii Framework Forum: $sort->defaultOrder and $sort->link() - Yii Framework Forum

Jump to content

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

$sort->defaultOrder and $sort->link() Rate Topic: -----

#1 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,003
  • Joined: 30-October 09
  • Location:UK

Posted 05 February 2010 - 07:02 AM

How to make the $sort->link() a different css class if it is assigned as $sort->defaultOrder?

Also how to make the $sort->link() be the opposite sort order (on first page load) of the assigned $sort->defaultOrder?
0

#2 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,003
  • Joined: 30-October 09
  • Location:UK

Posted 08 February 2010 - 04:31 AM

Anyone able to help?
0

#3 User is offline   Eliovir 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 17-January 09

Posted 08 February 2010 - 04:43 AM

I did not tried, but I read in CSort :
for the order :
        /**
         * @var string the default order that should be applied to the query criteria when
         * the current request does not specify any sort. For example, 'create_time DESC', or
         * 'name, create_time DESC'.
         */
        public $defaultOrder;


for the CSS, you could use htmlOptions
        /**
         * Generates a hyperlink that can be clicked to cause sorting.
         * @param string the attribute name. This must be the actual attribute name, not alias.
         * If it is an attribute of a related AR object, the name should be prefixed with
         * the relation name (e.g. 'author.name', where 'author' is the relation name).
         * @param string the link label. If null, the label will be determined according
         * to the attribute (see {@link resolveLabel}).
         * @param array additional HTML attributes for the hyperlink tag
         * @return string the generated hyperlink
         */
        public function link($attribute,$label=null,$htmlOptions=array())

0

#4 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,003
  • Joined: 30-October 09
  • Location:UK

Posted 08 February 2010 - 09:31 AM

Actually I want the current sort column to have a different CSS class applied to it when active.

And regarding default order, what I mean is if I specify a defaultOrder field of say "id asc", when I click the id column on first page load it does not reverse the order, it does "id asc" again.
0

#5 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,003
  • Joined: 30-October 09
  • Location:UK

Posted 10 February 2010 - 08:21 AM

Anyone able to help? Thanks!
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