這是JQ的前臺(tái)代碼
讓客戶(hù)滿(mǎn)意是我們工作的目標(biāo),不斷超越客戶(hù)的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶(hù),將通過(guò)不懈努力成為客戶(hù)在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名申請(qǐng)、雅安服務(wù)器托管、營(yíng)銷(xiāo)軟件、網(wǎng)站建設(shè)、赤峰林西網(wǎng)站維護(hù)、網(wǎng)站推廣。
function zTreeOnDrop(event, treeId, treeNodes, targetNode, moveType) {
var DeptIds = "";
for (var i = 0; i treeNodes.length; i++) {
DeptIds += treeNodes[i].DeptId;
if (i != treeNodes.length - 1) {
DeptIds += "|";
}
}
var params = "DeptIds=" + DeptIds + "TargetId=" + targetNode.DeptId;
$.submit({
url: "%=AppPath.Domain %/Controllers/CorpDeptInfoAction.ashx?__method=drag",
data: params,
success: function(oData) {
var treeObj = $.fn.zTree.getZTreeObj("rightTree");
for (var i = 0; i treeNodes.length; i++) {
treeObj.moveNode(targetNode, treeNodes[i], 'inner');
}
},
error: function(oData) {
$.alert(oData.Message);
}
});
};
function zTreeBeforeDrag(treeId, treeNodes) {
return true;
};
后臺(tái)代碼你自己改下
//移動(dòng)權(quán)限
private string Drag(HttpContext context)
{
string result = AppAction.ERROR;
string message = "";
log.Debug("[Update]: 更新權(quán)限表");
try
{
string DeptIds = context.Request.Form["DeptIds"];
string targetId = context.Request.Form["TargetId"];
string[] DeptIdList = DeptIds.Split('|');
IListCorpDeptInfo corpDeptInfoList = new ListCorpDeptInfo();
for (int i = 0; i DeptIdList.Length; i++)
{
CorpDeptInfo param = new CorpDeptInfo();
param.DeptId = DeptIdList[i];
CorpDeptInfo corpDeptInfo = corpDeptInfoService.GetCorpDeptInfoById(param);
corpDeptInfo.ParentId = targetId;
corpDeptInfoList.Add(corpDeptInfo);
}
int sResult = corpDeptInfoService.UpdateCorpDeptInfoListById(corpDeptInfoList);
switch (sResult)
{
case SystemRightService.SUCCESS:
result = AppAction.SUCCESS;
log.Debug("更新成功");
break;
default:
break;
}
}
catch (Exception ex)
{
message = "更新權(quán)限表失敗";
log.Error("更新失敗", ex);
}
Hashtable jsonHash = new Hashtable();
jsonHash.Add(AppAction.RESULT, result);
jsonHash.Add(AppAction.MESSAGE, message);
string jsonString = JsonMapper.ToJson(jsonHash);
return jsonString;
}
一,簡(jiǎn)介
ligerTree的功能列表:
1,支持本地?cái)?shù)據(jù)和服務(wù)器數(shù)據(jù)(配置data或者url)
2,支持原生html生成Tree
3,支持動(dòng)態(tài)獲取增加/修改/刪除節(jié)點(diǎn)
4,支持大部分常見(jiàn)的事件
5,支持獲取選中行等常見(jiàn)的接口方法
二,第一個(gè)例子
引入庫(kù)文件
遵循LigerUI系列插件的設(shè)計(jì)原則(插件盡量單獨(dú)),ligerTree是一個(gè)單獨(dú)的插件,也就是說(shuō)只需要引入plugins/ligerTree.js和樣式css文件就可以使用(當(dāng)然必須先引入jQuery),在這個(gè)例子中,我把tree用到的樣式和圖片分離了出來(lái),有興趣的朋友可以下載來(lái)看看
script src="lib/jquery/jquery-1.3.2.min.js" type="text/javascript"/script
link href="lib/ligerUI/skins/Aqua/css/ligerui-tree.css" rel="stylesheet" type="text/css" /
script src="lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"/script
你不必自己做了 jquery有很多插件實(shí)現(xiàn)樹(shù)狀分支,只要去jquery網(wǎng)查查插件就有了。可以推薦你一個(gè)ztree 國(guó)產(chǎn)的,功能十分豐富強(qiáng)大。我項(xiàng)目里也是用的它。
ztree異步加載節(jié)點(diǎn)的時(shí)候需要提供一個(gè)url。
ztree初始化完會(huì)向這個(gè)url發(fā)送一次請(qǐng)求【注意這個(gè)時(shí)候是不會(huì)帶參數(shù)的】。這個(gè)時(shí)候你需要返回給它你想要的節(jié)點(diǎn)。
ps:我是返回一個(gè)根節(jié)點(diǎn)給它。
然后在點(diǎn)擊此時(shí)的節(jié)點(diǎn)時(shí)候,還是會(huì)向這個(gè)url發(fā)送請(qǐng)求【此時(shí)會(huì)帶配置的參數(shù)】,如果你現(xiàn)在的處理方式和初始化之后那樣,就還是返回你開(kāi)始的那些節(jié)點(diǎn)給你。
所以,你需要根據(jù)不同的動(dòng)作來(lái)處理你的返回值。
async?:?{
enable?:?true,
url?:?_map.url,//異步路徑
autoParam?:?["id","name"?],//請(qǐng)求攜帶節(jié)點(diǎn)上的屬性值
dataFilter?:?function(treeId,?parentNode,?childNodes)?{
if?(!childNodes)return?null;
for?(var?i?=?0,?l?=?childNodes.length;?i??l;?i++)?{
var?_c=childNodes[i];
_c.isParent=_c.parent;
childNodes[i].name?=?_c.name.replace(/\.n/g,?'.');
}
return?childNodes;
}
},
//只是提供處理思路 不需要copy
@RequestMapping("/getOrg")
@ResponseBody
public? ListObjectTypeBean?getOrg(HttpServletRequest?request,ObjectTypeBean?bean,@RequestParam?MapString,String?para)?{
ListOrgBo?list?=?new?ArrayListOrgBo();
if(para.size()1){
OrgBo?bo?=?null;
bo?= orgService.getOrgByNo(GlobalValue.ORGROOT);
list.add(bo);
}else{
String?id?=?para.get("id");//根據(jù)父節(jié)點(diǎn)ID獲取子節(jié)點(diǎn)
list?=?orgTreeService.getChildOrgsForTree(id,Constants.DEFAULT_ORG_RELA_TYPE);//orgSpiService.getChildOrgs(id,?"");
}
ListObjectTypeBean???_list?=?new?ArrayListObjectTypeBean(list.size());
for(OrgBo?_b?:?list){
_list.add(new?ObjectTypeBean(_b.getNo(),?_b.getParentNo(),?_b.getShortName(),!_b.isLeaf()));
}
return?_list;
}
你是說(shuō)數(shù)據(jù)以樹(shù)形的方式顯示出來(lái)嗎?如果是的話(huà),我百度空間里有一個(gè)例子,你可以去參看一下,希望能幫上你的忙。
當(dāng)前文章:jquery結(jié)構(gòu)樹(shù),html樹(shù)形結(jié)構(gòu)
分享地址:http://www.chinadenli.net/article30/dseogso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開(kāi)發(fā)、手機(jī)網(wǎng)站建設(shè)、搜索引擎優(yōu)化、網(wǎng)站設(shè)計(jì)、微信小程序、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)