Yii Framework Forum: Problem With Sorting - Yii Framework Forum

Jump to content

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

Problem With Sorting Rate Topic: -----

#1 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 18 January 2013 - 12:21 AM

Hi

i have 2 models User and Calls with User has many Calls relationship.now i need to show data in cGridview,data is showing correctly but i need to apply sorting.in cGridview i had an attribute 'Called?' Which have value 'yes' or 'no' which represent if Calls Model Have a record corresponding to User.i am using a function in controller to show 'yes' or 'no' in cGridview based on Calls model have an entry or not. How can i implemet sorting on this field?thanks in advance
0

#2 User is offline   BCR 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 12-December 12

Posted 18 January 2013 - 02:18 AM

Pass the return value of that function to the dataProvider used for the GridView. For more, refer to this link: http://www.yiiframew...__1#entry189159
0

#3 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 18 January 2013 - 03:03 AM

thanks BCR for help

but can you tell me how can i "Pass the return value of that function to the dataProvider used for the GridView" as suggested by you

my guess from ex. is that it need to be define with following statement

$criteria->compare('filed','value',true);

can you explain a bit more?thanks
0

#4 User is offline   BCR 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 12-December 12

Posted 18 January 2013 - 04:48 AM

View Postprashant.tyagi, on 18 January 2013 - 03:03 AM, said:

thanks BCR for help

but can you tell me how can i "Pass the return value of that function to the dataProvider used for the GridView" as suggested by you

my guess from ex. is that it need to be define with following statement

$criteria->compare('filed','value',true);

can you explain a bit more?thanks


I'll need to have a look at your view & controller for that.
0

#5 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 20 January 2013 - 10:23 PM

this is the view

array(
'header'=>'Called?',
'name'=>'Called',
'type'=>'raw',
'value'=>array($this, 'ccaleadstatus'),
'htmlOptions'=>array(
'class'=> 'adminleadId',
)
) ,

this is in controller

public function ccaleadstatus($data) {

$return = isset($data->wish_ccacall["id"])?"Yes":"No";
return $return;
}
0

#6 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 21 January 2013 - 10:28 PM

anybody?
0

#7 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 08 February 2013 - 01:25 AM

Hi
Please can anybody tell me if i use a function to show value of a colomn in gridview and this function show value from database but if the value is not available in database then it show 'no' custom text.can anybody tell be how can i sort this colomn.thanks in advance.can somebody show this by example?thanks in advance
0

#8 User is offline   softark 

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

Posted 08 February 2013 - 03:23 AM

Hi prashant.tyagi,

This is a kind of STAT relation. It's relatively easy to display it in the grid.

But in order to filter/sort by this kind of calculated data, you need to do some trick. In short, we can make use of sub query in SELECT clause and in WHERE clause when we define the criteria.

Please take a look at this wiki article:
http://www.yiiframew...ms-in-cgridview
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