Yii Framework Forum: How to display line numbers in CGridView - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to display line numbers in CGridView Rate Topic: -----

#1 User is offline   Blue Sapphire 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 27-February 10

Posted 10 May 2010 - 07:46 AM

How can I display "line numbers" in a column of CGridView.

Note: These line numbers are not ID from database. These should be separate from it.

Can some one guide me in this regards.

Thanks in advance
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,523
  • Joined: 12-October 09
  • Location:Croatia

Posted 10 May 2010 - 08:23 AM

You can use $row for the value but it starts from 0 on every page

http://www.yiiframew...mn#value-detail
Find more about me.... btw. Do you know your WAN IP?
1

#3 User is offline   Blue Sapphire 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 27-February 10

Posted 10 May 2010 - 08:55 AM

Thanks for reply.

How to display other than that. Like in normal does (not starting from 0 on each page).
0

#4 User is offline   mrwizard 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-June 10

Posted 05 June 2010 - 10:37 AM

Create a column like this
array(
	'name'=>'id',
	'value'=>'$this->grid->dataProvider->getPagination()->getOffset()+$row+1',
	'header'=>'No.',
	'filter'=>false,
),


This could be anything you need.
Cheers
1

#5 User is offline   Key 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 07-May 10

Posted 05 June 2010 - 10:44 AM

View Postmrwizard, on 05 June 2010 - 10:37 AM, said:

Create a column like this
array(
	'name'=>'id',
	'value'=>'$this->grid->dataProvider->getPagination()->getOffset()+$row+1',
	'header'=>'No.',
	'filter'=>false,
),


This could be anything you need.
Cheers


Very nice, thanks :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users