tree:
buildTree = function() {
var _treenodeId='';//用于保存被点中的节点id
...//通过改变样式
var tree_right_left_css=function(node){
if(_treenodeId!==''&&_treenodeId!=node.id){
var _nodd=fileTree.getNodeById(_treenodeId);
if(_nodd){
_nodd.getUI().removeClass("x-tree-selected");
}
}
_treenodeId=node.id;
node.getUI().addClass('x-tree-selected');
}
--------------------------------------------
//通过selectionModel
var tree_right_left_select=function(node){
if(_treenodeId!==''&&_treenodeId!=node.id){
var _nodd=fileTree.getNodeById(_treenodeId);
if(_nodd){
fileTree.getSelectionModel().unselect(_nodd);
}
}
_treenodeId=node.id;
fileTree.getSelectionModel().select(node);
}
----------------------------------------------
...
fileTree.on('click', function(node, event) {//左键
tree_right_left_css(node);
});
fileTree.on('contextmenu', function(node, event) {//右键
tree_right_left_css(node);
});
}
grid:
buildGrid=function(parentId,containDel) {
var _filerowId='';//用于保存行 索引
...//创建过程
//改变样式
var file_Right_left_css=function(r){
var css='x-grid3-row-selected';
grid.getView().addRowClass(r,css)
if(_filerowId!==''&&_filerowId!=r){
grid.getView().removeRowClass(_filerowId,css);
}
_filerowId=r;
}
//通过selectionModel
var file_right_left_select=function(r){
if(_filerowId!=r){
fileGrid.getSelectionModel().selectRow(r);
fileGrid.getSelectionModel().deselectRow(_filerowId);
}
_filerowId=r;
}
fileGrid.on('rowclick',function(fileGrid,rowIndex,event){
file_Right_left_css(rowIndex);
});
fileGrid.on('rowcontextmenu',function(fileGrid,rowIndex,event){
file_Right_left_css(rowIndex);
});
}