0
votes

How can I set the selection for the row displaying a new record in CGridview of Yii.

For example: Upon adding a new record user is redirected to the grid view page, where it displays all records. Now i want to show the new record as selected/highlighted in gridview.

1
when my page load the new record should be selected without any click. - S.Sid
can you add more details, I am not able to understand what you are asking. - SuVeRa
i have add a new record and after it the page is redirect to my grid view page. where it display all records, now i want to show my new record as selected/highlight in gridview. - S.Sid
And what You want to do with selection? Or You want just visual differens of old records? - Sergey

1 Answers

1
votes
  1. Add in main.css

    .grid-view table.items tr.newrecord {
        background: none repeat scroll 0 0 #FF0000 !important; /* red color is new record */
    }
    
  2. In model of message

    function isNeedSelection()
    {
        return (strtotime($this->created) > time() - 5*60); // 5 minutes
    }
    
  3. In CGridView add row css class expression

    'rowCssClassExpression' => '$data->isNeedSelection()?"newrecord":$this->rowCssClass[$row%2]',