EasyUI Forum
September 12, 2025, 04:22:39 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: treeGrid - multiSelect rows only with CTRL or SHIFT key  (Read 17293 times)
amir-t
Newbie
*
Posts: 48


View Profile
« on: July 30, 2013, 10:06:12 AM »

Hi,

When enabling the multiSelect in treeGrid, by setting the 'singleSelect' property to "false",
The multi selected rows are selected on every 'Left mouse click',
instead of just by pressing the CTRL\SHIFT key + Left mouse click.

Is there any way to implement the multiSelect in that way?

We need a common multiSelect behavior:
multi rows will be selected only with CTRL\SHIFT key + Left mouse click,
and when pressing the Left mouse click (without holding CTRL\SHIFT key) on some other row - all the selections will be cleared and only the new current row will be selected.

I found an example for the required muliSelect behavior, in the following jsFiddle example:
http://jsfiddle.net/valchev/QBESY/

Thanks in advance.
« Last Edit: July 30, 2013, 10:11:35 AM by amir-t » Logged
amir-t
Newbie
*
Posts: 48


View Profile
« Reply #1 on: August 05, 2013, 04:28:35 AM »

Hi, still didn't succeed to fix the multiSelect issue.

I'll appreciate any help.

Tnx.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: August 07, 2013, 12:35:31 AM »

Here is the simple implementation of multiple selection with CTRL key.
Code:
var dg = $('#dg');
dg.datagrid({...});
var dc = dg.data('datagrid').dc;
var body = dc.body1.add(dc.body2);
body.unbind('click').bind('click',function(e){
var tr = $(e.target).closest('tr.datagrid-row');
var index = parseInt(tr.attr('datagrid-row-index'));
if (!e.ctrlKey){
dg.datagrid('clearSelections').datagrid('selectRow',index);
} else {
if (tr.hasClass('datagrid-row-selected')){
dg.datagrid('unselectRow',index);
} else {
dg.datagrid('selectRow',index);
}
}
});
Logged
amir-t
Newbie
*
Posts: 48


View Profile
« Reply #3 on: August 07, 2013, 11:41:56 PM »

Thanks.

Is this implementation is suitable For TreeGrid Component?

It seems that this implementation is for dataGrid, i guess its the same code for treeGrid with a bit of changes, but how can i convert to be used with TreeGrid?

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: August 08, 2013, 12:38:21 AM »

For treegrid please try the code below:
Code:
var tg = $('#tg');
tg.treegrid({...});  // create treegrid
var panel = tg.treegrid('getPanel');
var body1 = panel.find('div.datagrid-view1 div.datagrid-body-inner');
var body2 = panel.find('div.datagrid-view2 div.datagrid-body');
var body = body1.add(body2);  // the body container
body.unbind('click').bind('click',function(e){
var tr = $(e.target).closest('tr.datagrid-row');
var id = tr.attr('node-id');
if (!e.ctrlKey){
tg.treegrid('clearSelections').treegrid('selectRow',id);
} else {
if (tr.hasClass('datagrid-row-selected')){
tg.treegrid('unselectRow',id);
} else {
tg.treegrid('selectRow',id);
}
}
});
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!