Yii Framework Forum: Print Value From Selected Row Of Cgridview - Yii Framework Forum

Jump to content

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

Print Value From Selected Row Of Cgridview Rate Topic: -----

#1 User is offline   martinirojo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 06-October 12

Posted 16 October 2012 - 07:21 AM

Hi!
I need some help. When a row from CGridView is selected, I would like to print the second column value (Client Last name) from that row.
However, I'm not able to get the value from the column. Instead I get "object HTMLTableCellElement"

This is my code:
<script>
			
			function obtenerSeleccion(){
				var idCliente = $.fn.yiiGridView.getSelection('reclamos-cliente-grid');
				
				
				var selectedRowElements = $("#reclamos-cliente-grid .items tbody tr.selected td");
				if(selectedRowElements.length > 0 )
					alert(selectedRowElements[1]);

...
				


This is my grid widget
<?php 
			$this->widget('zii.widgets.grid.CGridView', array(
				'id'=>'reclamos-cliente-grid',
				'selectableRows'=>1,
				'selectionChanged'=>'obtenerSeleccion',	// via 1: para mostrar detalles al seleccionar
				'dataProvider'=>Cliente::model()->search(),
				'filter'=>Cliente::model(),
				'columns'=>array(
					'idCliente',
					'apellidos',
					'nombres',
					'calle',
					'numeroPuerta',
					//'piso',
					//'dpto',
					'localidad',
					'provincia',
					//'codigoPostal',
					//'telefono',
					//'email',
					//'tipoPlan',
					//'observaciones',
					
					
				),
			));
		?>


Thanks!

Attached File(s)


0

#2 User is offline   Keith 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 910
  • Joined: 04-March 10
  • Location:UK

Posted 16 October 2012 - 07:25 AM

alert(selectedRowElements[1].text());

0

#3 User is offline   martinirojo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 06-October 12

Posted 17 October 2012 - 02:03 PM

 Keith, on 16 October 2012 - 07:25 AM, said:

alert(selectedRowElements[1].text());



Now I'm getting an error: HTMLTableCellElement does not have text property.

What I'm trying to do actually is: below the grid Cgridview, show "Selected client: CLIENT_LAST_NAME"
Perhaps there is a better way compared to what I'm trying to do.

I'll apreciate your help.
Regards
0

#4 User is offline   Keith 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 910
  • Joined: 04-March 10
  • Location:UK

Posted 18 October 2012 - 02:48 AM

I feel like you should probably be indexing from 0. I didn't question that when copying your code originally. Try:

alert(selectedRowElements[0].text());

0

#5 User is offline   martinirojo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 06-October 12

Posted 03 November 2012 - 09:13 AM

 Keith, on 18 October 2012 - 02:48 AM, said:

I feel like you should probably be indexing from 0. I didn't question that when copying your code originally. Try:

alert(selectedRowElements[0].text());



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