/** * 树型获取同一级的所有节点重新排序 * id tree的id * targetNode DOM 对象,这个节点是被放置的目标 * return 数组 */ function TreeLevelNodeOrder(id,targetNode){ var parent = $('#'+id).tree('getParent', targetNode); //获取同一级节点 var nodeList = parent?$('#'+id).tree('getChildren',parent.target):$('#'+id).tree('getRoots'); var orders = new Array(); $.each(nodeList,function(i,val){ orders[i] = nodeList[i].id; }); return orders; }
HTML
<div class="table_search" id="search_box"> <div class="br"> <div class="item">XXX:<input type="text" id="no"/></div> <div class="item">XXX:<input type="text" id="realname" com="combotree"/></div> <div class="item"> XXX:<select id="is_order" class="easyui-combobox" style="width:50px" com="combobox"> <option value="">全部</option> <option value="1">是</option> <option value="0">否</option> </select> </div> <div class="clear"></div> </div> </div> <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" id="search_submit">搜索</a> <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true" id="search_reset">重置搜索</a> //搜索 $('#search_submit').click(function(){ table_search('#search_box .item',"table_id"); }); //重置 $('#search_reset').click(function(){ table_search_reset('#search_box .item',"table_id"); });
JS处理
/** * 表格搜索 */ function TableSearch(search_obj,id,action){ var data = {}; $(search_obj).children().each(function(){ var id = $(this).attr('id'); var com = $(this).attr('com');//选用哪一个组件 var multiple = $(this).attr('multiple');//多选 if(com){ if(multiple != undefined){ var val = eval("$(this)." + com + "('getValues')"); }else{ var val = eval("$(this)." + com + "('getValue')"); } }else{ var type = $(this).attr('type'); if(type == 'radio' || type == 'checkbox'){ var val = $('input:'+type+':checked').val(); }else{ var val = $(this).val(); } } if(val) data[id] = val; if($('#'+id+' select').length>0){ $('#'+id+' select').each(function(){ var key = $(this).attr('id'); if($(this).val()){ data[key] = $(this).val(); } }); } }); switch(action){ case 'treegrid': $('#'+id).treegrid('load',data); break; default:$('#'+id).datagrid('load',data); } } /** * 表格搜索重置 */ function TableSearchReset(search_obj,table){ $(search_obj).children().each(function(){ var com = $(this).attr('com'); if(com != undefined){ eval("$(this)." + com + "('clear')"); }else{ $(this).val(''); } var id = $(this).attr('id'); if($('#'+id+' select').length>0){ $('#'+id+' select').each(function(){ $(this).val(''); }); } }); $('#'+table).datagrid('load',{}); }