Yii Framework Forum: Gridview Mouseover Event - Yii Framework Forum

Jump to content

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

Gridview Mouseover Event Rate Topic: -----

#1 User is offline   deepu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 24-October 11
  • Location:delhi india

Posted 19 October 2012 - 06:38 AM

Hi, I want to display some details in case of a mouse over event on a particular cell of the Gridview thank you in advance
deepak
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,670
  • Joined: 04-March 10
  • Location:UK

Posted 19 October 2012 - 06:47 AM

For a particularly easy, js free implementation, you could just put the text into the "title" attribute of a div containing the data.

In your CGridView column configuration:
    'type'=>'html',
    'value'=>function($data){
        return CHtml::tag('div', array('title'=>'Hover text'), 'Cell content');
    },

1

#3 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 19 October 2012 - 07:00 AM

You can implement it with jQuery

<?php Yii::app()->clientScript->registerScript("mySuperAwesomeScript", "
    $('#yourGrid-id').on('mouseover mouseout', 'table tr', function(event) {
        if (event.type == 'mouseover') {
            /* show / display your details */
        } else if (event.type == 'mouseout') {
            /* hide / remove your details */
        }
    });
"); ?>


Edit: I really like Keith's approach. Mine is overdoing it :)

This post has been edited by bennouna: 19 October 2012 - 07:02 AM

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