EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rockccf on June 02, 2015, 03:00:43 AM



Title: Combobox editor in datagrid, pressing down arrow key to activate dropdown
Post by: rockccf on June 02, 2015, 03:00:43 AM
Hi,

About the combobox editor in datagrid, how to bind the down arrow key so whenever user press the down arrow key, the drop down will show, but when the drop down is displayed, up/down arrow key acts as default.
Currently the drop down list has to be triggered by using mouse and click on the cell.

It's a non-editable combobox.

Thanks.


Title: Re: Combobox editor in datagrid, pressing down arrow key to activate dropdown
Post by: jarry on June 02, 2015, 09:23:59 AM
Bind the 'keydown' event to the editing box. if the user press the DOWN key, call the 'showPanel' method to display the drop-down panel.
Code:
$('#dg').datagrid({
onBeginEdit: function(index,row){
var ed = $(this).datagrid('getEditor', {index:index,field:...});
if (ed){
$(ed.target).combobox('textbox').bind('keydown', function(e){
if (e.keyCode == 40){
var cc = $(ed.target);
if (cc.combobox('panel').panel('options').closed){
cc.combobox('showPanel');
}
}
})
}
}
})


Title: Re: Combobox editor in datagrid, pressing down arrow key to activate dropdown
Post by: rockccf on June 02, 2015, 08:44:46 PM
Great!
It works.
Thank you so much.