Yii Framework Forum: Double Clicking On Grid View Row Gives Unpredictable Results - Yii Framework Forum

Jump to content

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

Double Clicking On Grid View Row Gives Unpredictable Results Rate Topic: -----

#1 User is offline   Alec Smythe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 13-January 13

Posted 04 July 2014 - 01:55 PM

I'm not sure if this is a feature or a bug. For most of my admin views, I have code like this:

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'deposit-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'id',
		'club_id',
		'deposit_date',
		array(
			'class'=>'CButtonColumn',
		),
	),
	'selectionChanged'=>"function(id){window.location='" . Yii::app()->urlManager->createUrl('deposit') . "/' + $.fn.yiiGridView.getSelection(id);}",
)); ?>


With this setup, when I click on the grid view row, I get the view of that model.

However, I noticed yesterday, that if I double click on the row, sometimes I get the model view and sometimes I get the index view. It seems like in my development environment I get the model, but on the server I get the index view. It looks to me like maybe the double click is creating two calls. On the first click it retrieves the id okay and gives me the model view, but then it processes the second click. By that time, the page has changed enough that it can't retrieve the id, so it gives me the index view, which is basically the model view but without an id.

Anyone else run into this? Is it supposed to work like this? Any obvious work around that I am missing?
0

#2 User is offline   sirius 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 12-October 11

Posted 15 July 2014 - 02:56 AM

I have done something like this:
					'afterAjaxUpdate'=>'function(id, data){
						var gridTable = $(data).find("div#bicycle-grid>table");
						$("div#bicycle-grid>table>tbody>tr").bind("dblclick", function()
						{
							dblClickRow($(this));
						});
						}',


and made the function like this:
<script>
	$(document).ready(function()
	{
		$('#bicycle-grid>table>tbody>tr').dblclick(function()
		{
			dblClickRow($(this));
		});

	})
	function dblClickRow(theRow)
	{
		var theUrl = $(theRow).find('a.update').attr('href');
		window.location=theUrl;
	}
</script>

This worked for me, hope it will work for you as well.
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