$(function(){ $("#treeTaocan2").treegrid({ idField:'id', treeField:'text', nowrap: false, rownumbers: true, checkbox: true, lines: false, dnd: true, onlyLeafCheck: true, animate: true, collapsible: true, singleSelect: true, columns:[[ {title:'text',field:'text',180,formatter:function(value,rowData,rowIndex){ if(rowData.id!= "root" && rowData.id.indexOf("zu_")==-1) { //text 名称前面加复选框 return "<input type='checkbox' id='taocan_"+rowData.id+"' "+(rowData.checked?'checked':'')+"/>" + rowData.text; }else{ return rowData.text; } }}, {title:'price','field':'price',180}, {title:'price1','field':'price1',180} ]] }); $("#treeTaocan2").treegrid("loadData",data) //去掉结点前面的文件及文件夹小图标 $(".tree-icon,.tree-file").removeClass("tree-icon tree-file"); $(".tree-icon,.tree-folder").removeClass("tree-icon tree-folder tree-folder-open tree-folder-closed"); }); //获取选中的结点 function getSelected(){ var idList = ""; $("input:checked").each(function(){ var id = $(this).attr("id"); if(id.indexOf("taocan_")>-1) idList += id.replace("taocan_",'')+','; }) alert(idList); }