使用ArrayDataProvider,Yii2网格排序不正确

时间:2018-03-07 10:35:09

标签: yii2

我正在为网格视图小部件使用数组数据提供程序,因为数据源是API响应。它工作正常,但是当我尝试对“名称”列进行排序时,它使用小写的第一个字母排序错误。请检查表格网页截图。我收到的API响应在当前排序中是正确的。

1。表格

Click here to view

2。模型

$provider = new ArrayDataProvider([
        'allModels' => @$response->data,
        'pagination' => false,
        'sort' => [
            'attributes' => ['id', 'name', 'shortDescription'],
        ],
    ]);

第3。图

<?= GridView::widget([
'  dataProvider' => $dataProvider,
    'columns' => [
       'id',
       'name',
       'shortDescription'
     ],
  'options' => ['class' => 'content'],
  'tableOptions' => ['class' => 'table table-striped table-hover'],
  'summary' => Yii::t('app', 'Showing').' {begin}-{end} of '.$total.' '.Yii::t('app', 'items')
]); 
?>

请指导我解决这个问题。谢谢!

0 个答案:

没有答案