I'm getting some data using a webservice which is in JSON format and want to dispaly them using gridview. I use ArrayDataProvider to send data to the gridview using this code:
$dataProvider = new ArrayDataProvider([
'allModels' => $data,
'pagination' => [
'pageSize' => 10,
],
'sort' => [
'attributes' => ['fname', 'lname', 'age', 'email'],
],
]);
How can I change label of columns in grid? For example First Name instead of fname?
Thank you.
I found the answer for this url https://github.com/yiisoft/yii2/issues/11490
Add a new property ArrayDataProvider::modelClass to manually specify which model ArrayDataProvider must use to generate column labels. This change will allow ArrayDataProvider to correctly generate column labels using Model::getAttributeLabel() method when provided data array is empty.