Jijgee
(Davaahuu J)
1
How to automatically numbering rows of cgridview?
I found some codes in the internet, but doesn’t work.
Error "Trying to get property of non-object " is displayed.
array(
'header'=>'No.',
'value'=>'$this->grid->dataProvider->pagination->currentPage *$this->grid->dataProvider->pagination->pageSize + ($row+1)',
),
seenivasan
(Chellamnivas)
2
Dear Jijgee
I hope the following is helpful.
array(
'header'=>"rowNo",
'value'=>'($this->grid->dataProvider->pagination->currentPage*
$this->grid->dataProvider->pagination->pageSize
)+
array_search($data,$this->grid->dataProvider->getData())+1',
),
Regards.
Jijgee
(Davaahuu J)
3
Thank you. Your solution works.
I found my mistake. In my case, it’s just simply
array(
‘header’=>’#’,
‘value’=>’$row+1’
).
Error "Trying to get property of non-object " means that there is no pagination because I sat pagination of CArrayDataProvider to false.
array(
'header'=>'No.',
'value'=>'array_search($data,$this->grid->dataProvider->getData())+1',
),
Use it for pagination false.