I’m sorry, I’m still learning a lot as I go, I don’t know all the terms and whatnot. But I’m working with Multicraft’s Panel, which is written using Yii. In the User’s view, if you’re staff it displays a view like this
I want to be able to sort by the two other columns that currently aren’t filterable. I’ve gathered that they work like this:
The columns have their own classes defined, in the classes, they use RenderDataCellContent functions that get data from a function in the User model based on a function in there.
For example, here’s the View column, Class Component and Model for FTP Access / FTP Username
View
$cols[] = array(
‘class’=>‘FtpAccessDropdownColumn’,
‘header’=>Yii::t(‘mc’, ‘FTP access / FTP username’),
);
Model
public function getServerFtpAccess($server, $local = false)
{
if ($local)
{
$permissionList = Yii::app()->bridgeDb->createCommand(‘selectperms
fromftp_user_server
where ’
.’server_id
=? anduser_id
=(selectid
fromftp_user
wherename
=?)’)
->queryColumn(array($server, $this->name));
}
else
{
$permissionList = Yii::app()->bridgeDb->createCommand(‘selectperms
fromftp_user_server
where ’
.’(server_id
=0 orserver_id
=(selectid
fromserver
whereid
=? andsuspended
=0)) ’
.‘anduser_id
=(selectid
fromftp_user
wherename
=?)’)
->queryColumn(array($server, $this->name));
}
$permissions = ‘’;
foreach ($permissionList as $perm)
if (strlen($perm) > strlen($permissions))
$permissions = $perm;
if ($permissions == ‘elradfmw’)
return ‘rw’;
if ($permissions == ‘elr’)
return ‘ro’;
return ‘’;
}
Class
class FtpAccessDropdownColumn extends CGridColumn
{
protected function renderDataCellContent($row, $data)
{
if (Yii::app()->params[‘view_role’] == ‘admin’)
return;
$access = $data->getServerFtpAccess(Yii::app()->params[‘view_server_id’], true);
$options = array(
‘’ => Yii::t(‘mc’, ‘No Access’),
‘ro’ => Yii::t(‘mc’, ‘Read only’),
‘rw’ => Yii::t(‘mc’, ‘Full access’)
);
echo CHtml::dropDownList(‘ftpAccess_’.$data->id, $access, $options,
array(‘ajax’=>array(‘type’=>‘POST’, ‘data’=>array(‘ajax’=>‘ftpAccess’, ‘user’=>$data->id,
Yii::app()->request->csrfTokenName=>Yii::app()->request->csrfToken,
‘ftpAccess’=>“js:$(’#ftpAccess_”.$data->id."’).val()"),
‘success’=>‘js:function(e) {if(e)alert(e);}’), ‘class’=>‘form-control ftp_access’));
echo ’ ‘.CHtml::encode($data->name).’.’.Yii::app()->params[‘view_server_id’];
}
}
I’ve tried a lot of different things, largely playing with how I can invoke CSort, but no matter what I do, the heading remains as normal text and is not sortable.
Any help to even start understanding what’s needed here would be super helpful.