Difference between #3 and #4 of
CGridView keep focus on the control after filtering

Revision #4 has been created by jayala on Mar 24, 2012, 4:46:49 PM with the memo:

Fixed an error that made it work just once
« previous (#3)

Changes

Title unchanged

CGridView keep focus on the control after filtering

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

CGridView, filter

Content changed

[...]
The first thing to do is register default handlers(filter change and afterAjaxUpdate) and register the cursorEnd function.
You can add filter change event anywhere on the page.

```php
//
Default handler for filter change event
 
$(function(){
 
$('input,select', '.grid-view tr.filters'
Configure all GridViews in the page
 
$(function(){
 
setupGridView();
 
});
 
 
// Setup the filter(s) controls
 
function setupGridView(grid)
 
{
 
if(grid==null)
 
grid = '.grid-view tr.filters';
 
// Default handler for filter change event
 
$('input,select', grid
).change(function() { var grid = $(this).closest('.grid-view'); $(document).data(grid.attr('id')+'-lastFocused', this.name); }); });

// Default handler for beforeAjaxUpdate event
[...]
fe.focus();
}
// Setup the new filter controls
 
setupGridView(grid);
 
}

// Place the cursor at the end of the text field
jQuery.fn.cursorEnd = function()
{
return this.each(function(){
[...]
5 0
10 followers
Viewed: 17 456 times
Version: 1.1
Category: How-tos
Written by: jayala
Last updated by: jayala
Created on: Feb 22, 2012
Last updated: 12 years ago
Update Article

Revisions

View all history