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
Page 1 of 1
Problem With Sorting
#2
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
#3
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
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
#4
Posted 18 January 2013 - 04:48 AM
prashant.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
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.
#5
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;
}
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;
}
#7
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
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
#8
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
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
Share this topic:
Page 1 of 1

Help












