I am using a combogrid for load data to insert into datagrid. I call the insert data to datagrid in onSelect. Thats mean when i select any data or press down key to scroll all my data then those rows will be selected any inserted automatically . But i want to look through the rows but only when i press inter then the selected row will be inserted.
I am trying this by using KeyUp function. But this wont working.
This is my previous code:
Combogrid add to row
function combogridData() {
var g = $('#itemListGrid').combogrid('grid'); // get datagrid object
var r = g.datagrid('getSelected'); // get the selected row
$('#itemListGrid').keyup(function(e){
if(e.keyCode == 13)
{
addrowtogrid(r);
}
});
$('#itemListGrid').combogrid('clear');
}
My Combogrid :
<select id="itemListGrid" class="easyui-combogrid" style="width:100%" data-options="
panelWidth: 600,
loader: myloader,
mode: 'remote',
idField: 'book_id',
textField: 'name',
method: 'get',
value: '',
columns: [[
{field:'book_id',title:'Item ID',width:'7%'},
{field:'name',title:'Book Name',width:'48%'},
{field:'retail',title:'retail',width:'5%',align:'right',hidden:true},
{field:'local_sale',title:'local',width:'7%',align:'right'},
{field:'whole_sale',title:'Whole',width:'8%',align:'right'},
{field:'isbn',title:'ISBN',width:'15%'},
{field:'authors',title:'Authors',width:'15%'},
]],
fitColumns: true,
labelPosition: 'top',
onSelect:combogridData ">
I am trying by using this code :
function combogridData() {
var g = $('#itemListGrid').combogrid('grid'); // get datagrid object
var r = g.datagrid('getSelected'); // get the selected row
$('#itemListGrid').keyup(function(e){
if(e.keyCode == 13)
{
addrowtogrid(r);
}
});
$('#itemListGrid').combogrid('clear');
}
I got My Own solution. don't need to add onSelect anymore. Just added
$('#itemListGrid').combogrid('textbox').bind('keyup', function(e){
if (e.keyCode == 13){ // when press ENTER key, accept the inputed value.
var g = $('#itemListGrid').combogrid('grid'); //get the combogrid
var r = g.datagrid('getSelected'); //get selected value
addrowtogrid(r); //add to another datagrid
}
});
under JQuery document.ready(). It's working perfectly. Thanks.