EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: acreonte82 on January 28, 2014, 06:50:27 AM



Title: ComboGrid multiple select by typing value
Post by: acreonte82 on January 28, 2014, 06:50:27 AM
Hello to all,
I've define a combogrid with multiple select
Code:
$('#id_RS_to_search').combogrid({
 panelWidth:500,
 url: 'controller/search_snp.php?protocol=<?php echo $_SESSION['protocol'?>',
 idField:'id_RS',
 textField:'id_RS',
 mode:'remote',
 multiple: true,
 fitColumns:true,
 columns:[[
{field:'ck',checkbox:true},
{field:'id_RS',title:'id_RS',width:250},
{field:'snp_name_lab',title:'snp_name_lab',width:250}
 ]]
});

my question is: when I select one element, how can I continue to select an other one by typing a new value?
For example I want to search one element typing the right name, then after select continue to select other element different from the first (in the same list)

At the moment and in the various example define in the documentation, is not possibile to select multiple item typing directly but only by click on it.

Can someone help me?

Thanks


Title: Re: ComboGrid multiple select by typing value
Post by: acreonte82 on January 30, 2014, 03:37:44 AM

stworthy can you help me?


Title: Re: ComboGrid multiple select by typing value
Post by: stworthy on January 30, 2014, 08:05:39 AM
This feature is not supported in current version. It has been sent to our developing team.


Title: Re: ComboGrid multiple select by typing value
Post by: acreonte82 on January 31, 2014, 01:28:42 AM
Thanks!!! Really!!
I wait the new feature


Title: Re: ComboGrid multiple select by typing value
Post by: stworthy on February 02, 2014, 08:29:05 AM
A possible solution to solve this issue is to override the keyHandler options. Please include the code below to the page.
Code:
<script>
$.extend($.fn.combogrid.defaults.keyHandler, {
enter: function(e){
var target = this;
var state = $.data(target, 'combogrid');
var opts = state.options;
var grid = state.grid;
var tr = opts.finder.getTr(grid[0], null, 'highlight');
if (!tr.length){
tr = opts.finder.getTr(grid[0], null, 'selected');
}
if (!tr.length){return}

state.remainText = false;
var index = parseInt(tr.attr('datagrid-row-index'));
if (opts.multiple){
var vv = [];
var ss = grid.datagrid('getSelections');
for(var i=0; i<ss.length; i++){
vv.push(ss[i][opts.idField]);
}
$(target).combogrid('setValues', vv);
} else {
grid.datagrid('selectRow', index);
$(target).combogrid('hidePanel');
}
},
query: function(q, e){
var target = this;
var state = $.data(target, 'combogrid');
var opts = state.options;
var grid = state.grid;
state.remainText = true;

if (opts.multiple && !q){
$(target).combogrid('setValues', []);
} else {
$(target).combogrid('setValues', [q]);
}

if (opts.mode == 'remote'){
grid.datagrid('clearSelections');
grid.datagrid('load', $.extend({}, opts.queryParams, {q:q}));
} else {
if (!q) return;
grid.datagrid('clearSelections');
var rows = grid.datagrid('getRows');
var qq = q.split(opts.separator);
for(var j=0; j<qq.length; j++){
var q = qq[j];
if (!q){continue;}
for(var i=0; i<rows.length; i++){
if (opts.filter.call(target, q, rows[i])){
grid.datagrid('selectRow', i);
}
}
}
}
}
});
</script>


Title: Re: ComboGrid multiple select by typing value
Post by: acreonte82 on February 10, 2014, 01:46:28 AM
I copied it but no difference...
how  can I include the extension?


Title: Re: ComboGrid multiple select by typing value
Post by: stworthy on February 10, 2014, 08:56:10 AM
Please refer to this example http://jsfiddle.net/Bz9Js/.


Title: Re: ComboGrid multiple select by typing value
Post by: acreonte82 on February 19, 2014, 01:24:56 AM
Thanks! Works!

Maybe can be a great idea to implement this function as standard for jeasyui

What do u think stworthy ?


Title: Re: ComboGrid multiple select by typing value
Post by: stworthy on February 19, 2014, 01:30:14 AM
Yes, this feature will be improved in next version. This requirement has been posted to our developing team.