treegrid and datagrid ctrl or shift selectRow

 1 var tg = $('#tg');
 2 tg.treegrid({...});  // create treegrid
 3 var panel = tg.treegrid('getPanel');
 4 var body1 = panel.find('div.datagrid-view1 div.datagrid-body-inner');
 5 var body2 = panel.find('div.datagrid-view2 div.datagrid-body');
 6 var body = body1.add(body2);  // the body container
 7 body.unbind('click').bind('click',function(e){
 8     var tr = $(e.target).closest('tr.datagrid-row');
 9     var id = tr.attr('node-id');
10     if (!e.ctrlKey){
11         tg.treegrid('clearSelections').treegrid('selectRow',id);
12     } else {
13         if (tr.hasClass('datagrid-row-selected')){
14             tg.treegrid('unselectRow',id);
15         } else {
16             tg.treegrid('selectRow',id);
17         }
18     }
19 });
 1 var dg = $('#dg');
 2 dg.datagrid({...});
 3 var dc = dg.data('datagrid').dc;
 4 var body = dc.body1.add(dc.body2);
 5 body.unbind('click').bind('click',function(e){
 6     var tr = $(e.target).closest('tr.datagrid-row');
 7     var index = parseInt(tr.attr('datagrid-row-index'));
 8     if (!e.ctrlKey){
 9         dg.datagrid('clearSelections').datagrid('selectRow',index);
10     } else {
11         if (tr.hasClass('datagrid-row-selected')){
12             dg.datagrid('unselectRow',index);
13         } else {
14             dg.datagrid('selectRow',index);
15         }
16     }
17 });

转自 : http://www.jeasyui.com/forum/index.php?topic=2001.0

posted @ 2013-08-09 17:18  少爵  阅读(1038)  评论(0编辑  收藏  举报