EasyUI Forum
May 16, 2024, 04:27:52 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Multiple Select on Combogrid like in Combobox  (Read 21613 times)
acreonte82
Jr. Member
**
Posts: 85



View Profile
« on: August 14, 2014, 07:50:44 AM »

Hello to all , Hello stworthy Grin

I'm trying to find a solution to have the multiple Select in a combogrid , but server side
This is my solution but not work well:
this is js
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}
]]
});


And this my php script
Code:
if (isset($_REQUEST['protocol'])){

if (isset($_REQUEST['q']) && (!empty($_REQUEST['q']))){
$polimorfismi =$_REQUEST['q']);
$array_polimorfismi=array();

$snp_app='';
$snp='';


#controllo se ho piĆ¹ polimorfismi selezionati
if (preg_match("/\,/", $polimorfismi)){
$array_polimorfismi=preg_split('/\,/',$polimorfismi);

$numero_polimorfismi_inseriti=count($array_polimorfismi);
}else{
$numero_polimorfismi_inseriti=1;
array_push($array_polimorfismi, $polimorfismi);
}
#genero in automatico le condizioni di ricerca
for ($i=0;$i<=$numero_polimorfismi_inseriti;$i++){
if (!empty($array_polimorfismi[$i])){
$app=$array_polimorfismi[$i];//." ".$snp_name_lab;
$snp_app= $snp_app." snps.id_RS LIKE '$app%'
OR snps.snp_name_lab LIKE '$app%' OR ";
$app="";
$snp_name_lab="";
}
}
$snp=substr($snp_app, 0, strlen($snp_app)-3);


$sql=" SELECT snps.id_RS, snps.snp_name_lab
FROM snps ,snps_protocol
WHERE snps_protocol.protocol='".$_REQUEST['protocol']."'
AND snps_protocol.id_rs=snps.id_rs
AND(".$snp.")";
#echo $sql;

}else{
$sql=" SELECT snps.id_RS, snps.snp_name_lab
FROM snps ,snps_protocol
WHERE snps_protocol.protocol='".$_REQUEST['protocol']."'
AND snps_protocol.id_rs=snps.id_rs
";
#echo $sql;
}

If I try to write two different value in the combogrid, using the ",", the result is that the combobox select only the last one...
Or if I try to selcet one and then only write my value, the result is that I have only the first value selected

Can u help me?

Thanks
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #1 on: August 15, 2014, 04:20:34 AM »

stworthy  can u help me?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: August 15, 2014, 03:50:52 PM »

What do you mean 'multiple Select in a combogrid , but server side'? Could you please explain it in more detail.
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #3 on: August 16, 2014, 07:30:49 AM »

Yes I'm sorry stworthy

I want to implement a multiple select in a combogrid  and retrive the data in remote mode.

So if the user select a first value and then write a second value , I want that the system display all possibile values (like a live search)

Your team developed a solutions for the Combobox called "Multiple select".
In my previous post I show you what I did ...

I hope to have clarified what I want
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #4 on: August 16, 2014, 07:43:19 AM »

Seems that if u try to press the "Enter" key to select the value, the system delete the value...

Can be an issue?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: August 16, 2014, 05:10:23 PM »

When using combogrid component, the 'idField','valueField' and 'textField' properties must be defined. If the combogrid component is in 'remote' mode, it will retrieve data when the inputed text is changed. When the ENTER key is pressed, the inputed text will be updated according to the selected rows of datagrid. So in order to let the component know what rows should be selected, the user must return the selected rows to the browser and then call 'selectRow' method to select some specify rows.
Code:
$('#cg').combogrid({
width:300,
idField:'id',
valueField:'id',
textField:'firstname',
multiple:true,
mode:'remote',
url:'test.php',
columns:[[
{field:'firstname',title:'firstname',width:100},
{field:'lastname',title:'lastname',width:100}
]],
onLoadSuccess:function(data){
var g = $('#cg').combogrid('grid');
$.map(data.selected || [], function(id){
g.datagrid('selectRow', g.datagrid('getRowIndex',id));
});
}
});
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #6 on: August 17, 2014, 06:51:22 AM »

In the image attached you can see what happen if I try to search some elements.
The combogrid show the other elements selected, but if you type a new one you have to remember to select the other elements, previously selected.

And if I try to search only one element and I try to press "Enter Key", the value searched is deleted.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 on: August 17, 2014, 04:13:18 PM »

You can try to override the 'ENTER' key handler for combogrid component.
Code:
$.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');
state.remainText = false;
if (tr.length){
var index = parseInt(tr.attr('datagrid-row-index'));
if (opts.multiple){
if (tr.hasClass('datagrid-row-selected')){
grid.datagrid('unselectRow', index);
} else {
grid.datagrid('selectRow', index);
}
} else {
grid.datagrid('selectRow', index);
}
}
var vv = [];
$.map(grid.datagrid('getSelections'), function(row){
vv.push(row[opts.idField]);
});
$(target).combogrid('setValues', vv);
if (!opts.multiple){
$(target).combogrid('hidePanel');
}
}
})
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #8 on: August 18, 2014, 01:20:20 AM »

Don't work, the same problem...

I put the overide function in the
Code:
$(document).ready(function () {
position... maybe I wrong
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #9 on: August 18, 2014, 02:34:47 AM »

Run the code directly in <script> tag.
Code:
<script>
$.extend($.fn.combogrid.defaults.keyHandler,{
enter: function(e){
//...
}
});
</script>
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #10 on: August 23, 2014, 01:06:48 AM »

No change...
Nothing... boh at this time I try to find an other solution...
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!