Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kendogrid filter menu closing on mouseleave

in a kendogrid with kendogrid.columnMenu: true like this http://jsbin.com/AsEtoDik/2

there's a very annoying behavior: when you try to set a filter and the mouse goes out of the filter panel, it closes. It happens a lot especially filtering on a date column.

I guess this is intended but it's not very user friendly. I thought about setting a timer after the mouseleave event, delaying the closure of the menu, in jQuery but it looks rather difficult and I'd appreciate some help or suggestion

like image 939
Vland Avatar asked Dec 23 '13 02:12

Vland


2 Answers

You can disable this behavior by replacing the Kendo Menu _mouseleave method (before you create the first instance):

kendo.ui.Menu.fn._mouseleave = function() {};

Then you'll have to click outside of the menu to close it (demo). You can try your idea with the timeout, although there might be complications; something like this might work - haven't tested much though (demo):

var originalMouseLeave = kendo.ui.Menu.fn._mouseleave;
var mouseLeave = function (e) {
    var that = this;
    clearTimeout(this._timeoutHandle);
    this._timeoutHandle = setTimeout(function () {
        originalMouseLeave.call(that, e);
    }, 1000);
}

kendo.ui.Menu.fn._mouseleave = mouseLeave;

var originalMouseEnter = kendo.ui.Menu.fn._mouseenter;
var mouseEnter = function (e) {
    clearTimeout(this._timeoutHandle);
    originalMouseEnter.call(this, e);
}

kendo.ui.Menu.fn._mouseenter = mouseEnter;

Note: there's also the hoverDelay configuration option, so you may be able to set the default option for that.

like image 165
Lars Höppner Avatar answered Oct 01 '22 19:10

Lars Höppner


A workaround that isn't as version dependent is to simply focus on another element in the filter menu, as discussed in the Telerik forum here and demonstrated in a demo here.

They provide two solutions in the example code (one is commented out), I prefer the second as it doesn't highlight the filter's first dropdown.

$(document).ready(function() {
    $("#grid").kendoGrid({
        dataSource: {...},
        height: 550,
        scrollable: true,
        sortable: true,
        columnMenu: true,
        filterable: true,
        pageable: {...},
        
        // *** workaround ***
        columnMenuInit: function(e){
          var menu = e.container.find(".k-menu").data("kendoMenu");
          menu.bind('activate', function(e){
            if(e.item.is('.k-filter-item')){
              // if an element in the submenu is focused first, the issue is not observed
              e.item.find('input').first().focus();
            }
          });
        },
        
        columns: [...]
    });
  });
like image 45
Seth Rickard Avatar answered Oct 01 '22 18:10

Seth Rickard