




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
ExtJSHomeHome?02.技術?ExtJSTreeGrid葉子節(jié)點拖拽問題和選擇框使用方ExtJSTreeGrid葉子節(jié)點拖拽問題和選PostedbyLittleHorse2011年1109日-Postedin:02.技術- 1.TreeGrid我使用的是ExtJs3.1版本。ExtJs中默認在樹(Ext.tree.TreePanel)的拖動中,境葉子節(jié)點是有可能變?yōu)楦腹?jié)點的 TreePanel的1 er",varn=3if(n.leaf) n.leaf= 7在上面 處理函數中加打印語句,發(fā)現在TreeGrid有葉子節(jié)點被drop時 試著調試一下,把頁面引入的ext-all.js換成ext-all-debug.js,從觸發(fā) er的地方入手逐漸分析,最終發(fā)現當TreePanel的拖拽配置為dropConfig:{appendOnly:true}時,nodedra er是不會觸發(fā)的。這里TreePanel和TreeGrid的區(qū)別是,TreePanel如果不設置dropConfig屬性,默認appendOnly是false;而TreeGrid如果不設置dropConfig屬性,默認appendOnly是true。所以同樣的處理到了TreeGrid這里就無效了。明白了原因,只需要在TreeGrid的配 {appendOnly:false}和上面的nodedra 處理函數就能實現TreeGrid的葉子節(jié)點drop問題,效果如下:EXTJS一、描述:通過dwr實現JS與的交互,從而實現動態(tài)樹中葉子節(jié)點和 節(jié)點下的相關節(jié)點的序號,能使得與前臺同步。這個序號借助了tree中node的index。1servlet、mysql、dwr、2ExtJs、tree、window以及機3ExtJsExtJsExtJs動態(tài)樹-右 節(jié)點菜ExtJs動態(tài)樹-選擇右 節(jié)點菜單的“編輯”選ExtJs456Javapackageimportimportpublicclass DBConn{ privatestatic url= = = privatestatic driver= public ConnectionConnection =conn= }catch(Exception} }2、daoJavapackageimportimportimportimportimportimportimportimportimportcom.demo.navigate.model.Navigate;public NavigateDaoprivate NavigateDaoprivate}public NavigateDao ==dao new ID @param Navigateget(SerializableConnectionconection Statement ResultSet Navigate conection= stmt StringBuffer new navigate id rs obj ; }catch(Exception { catche) =} { catch} =}(conection null) { catch}conection }}catch(Exception}} } @parampublicList<Navigate>List<Navigate>list= Connectionconection Statement ResultSet conection=stmt StringBuffer navigate =sql.append(" rs obj new ; } {;} {} } null){{} }stmt }(conection { try } ption conection=; }catch(Exception return ** publicvoidsave(NavigateStringBuffersql= newStringBuffer("insert navigate(parentId,title,leaf,number,url)}** publicvoidupdate(NavigateStringBuffersql= newStringBuffer("updatenavigateset");sql.append("parentId=sql.append("title sql.append("leaf sql.append("number sql.append(",url sql.append("'where = ** * *@returntrue-修改成功falsepublicBooleanajaxUpdateTitle(Integerg title){Boolean =Navigate =if(null StringBuffersql= uffer("updatenavigateset");sql.append("title sql.append("where }}** publicvoidremoveById(IntegerStringBuffersql= newStringBuffer("dnavigatewhereid =");}** * publicvoidajaxRemoveNode(IntegerList (Objectobject list);Navigate }}** * 點* ne 節(jié)點移動后的目標父點* 置publicvoidajaxMoveNode(intid, nerentId,intNavigate = minIndex= maxIndex=if(oldParentId== &&minIndex!= if(minIndex minIndex, if(minIndex } }if(oldParentId ne //1 this.downNode(oldParentId,ex,- this.upNode(nerentId, - obj.setParentId(ne}}** *@param *@param publicvoiddownNode(int StringBuffersql= newStringBuffer("updatenavigateset 1 if(maxIndex!=- <=}if(minIndex!=-sql.append("and }}**@param *@param *@param publicvoidupNode(intparentId, int StringBuffersql new number=number+1 parentId=if(maxIndex!=-<}if(minIndex!=-sql.append("and}}** publicvoidbulkUpdate(StringConnectionconection Statementstmt conection =conection.createStatement}catch(Exception {{{} }stmt }(conection {{{} }conection=}}catch(Exception}} }3、ServiceJavapackageimportimportimportimportpublic NavigateManagerprivateNavigateDao =publicNavigateget(Serializable @parampublicList<Navigate>getChildrenById(Integer @parampublic save(Navigate @parampublic update(Navigate @parampublic removeById(Integer @param @param @returntrue-修改成功falsepublicBoolean ajaxUpdateTitle(Integerid,Stringti dao.ajaxUpdateTitle(id, @parampublic ajaxRemoveNode(IntegerNavigate dao.downNode(obj.getParentId(), - @param @param @param @param publicvoid ajaxMoveNode(intid, intoldParentId,intnerentId,intnodeIndex){dao.ajaxMoveNode(id,oldParentId,ne 4、ServletJavapackageimportimportimportimportimportimportimportimportcom.demo.navigate.service.NavigateManager;public NavigateEditServletextendsHttpServletpublicvoid doGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,{this.doPost(request, publicvoid doPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,{ idstr parentId=request.getParameter("pare leaf number= Navigate !=NavigateManagernavigateManager= obj obj newobj.setParentId(new;obj.setLeaf(newobj.setNumber(new request.setAttribute("obj",RequestDispatcherdispatcher= dispatcher.forward(request, Javapackageimportimportimportimportimportimportimportimportcom.demo.navigate.service.NavigateManager;public NavigateSaveServletextendsHttpServletpublicvoid doGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,{this.doPost(request, publicvoid doPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,{NavigateManagernavigateManager= newNavigNavigate request.setCharacterEncoding("UTF- id number= parentId=request.getParameter("pare leaf title ; url &&= }obj newobj.setLeaf(newobj.setParentId(new;} != && RequestDispatcherdispatcher= dispatcher.forward(request, Javapackageimportimportimportimportimportimportimportcom.demo.navigate.service.NavigateManager;public NavigateJsonServletextendsHttpServletpublicvoid doGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,{this.doPost(request, publicvoid doPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,{NavigateManagernavigateManager= newNavigrequest.setAttribute("list",navigateManager.getChildrenById(newInteger(request.getParameter("id"))));RequestDispatcherdispatcher= dispatcher.forward(request, Html<%@ contentType="text/html;charset=UTF-8"<%@taglib /jsp/jstl/core"prefix="c <%@ <base<title>菜單編輯<linkrel="stylesheet"type="text/css"/ext/resources/css/ext- <scripttype="text/javascript"src="scripts/ext/adapt<scripttype="text/javascript"src="scripts/ext/ext-<scriptfunctionif(form.parentId.value== ||form.leaf.value==""){Ext.Msg.alert(return}if(form.title.value==Ext.Msg.alert(return}}<bodystyle="background-color:<formaction="navigatesave"method="post"onsubmit="returncheckForm(this)"><inputtype="hidden"name="id"value="${obj.<inputtype="hidden"name="parentId"<inputtype="hidden"name="leaf"value="${ob<inputtype="hidden"name="number"value="${<table<tr><tdwidth="60"><td><inputtype="text" title"value="${obj.title}"/></td></tr><c:if<td><inputtype="text" url"value="${obj.url}"/></td></tr><tr><td <input value="&;&<inputtype="reset"ame="reset"value="&;&<input value=" Html<%@page language="java"contentType="text/html;charset=UTpageEncoding="UTF-<!DOCTYPEhtml //W3C//DTDHTML4.01 Transitional//EN""<metahttp-Type"content="text/html;charset=UTF-<title>信息更新成功<script Html<%@ contentType="text/html;charset=UTF-8"<%@taglib /jsp/jstl/core"prefix="c <%@taglib /jsp/jstl/functions"prefix="fn"%><c:setvar="len"value="${fn:length(list)-1}"[<c:forEachitems="${list}"var="obj"{<c:iftest="${obj.leaf==<c:ifHtml<%@ language="java"pageEncoding="UTF-String =StringbasePath= jsJs var ="if(typeof(glbRootPath)!=basePath 5. FormEditWin= return : :showAddDirWin function(parentNode)//顯示添加 窗varnumber= ntNode.lastChild)+ vareditpage parentNode.id leaf=0&number=" varwindow 節(jié)點 editpage,function()showAddLeafWin {//=+ parentNode.id leaf=1&number=" varwindow= new","新建葉子節(jié)點", editpage,function(){ showEditDirWin function(node)//顯 編輯窗vareditpage + varwindow= this.createWin("win"+node.id,node.text,editpage,function(){ varnodeparent= vartree nodeparent.on("expand",function(pnode){ this, single showEditLeafWin function(node)//vareditpage + varwindow= this.createWin("win"+node.id,node.text,editpage,function(){ varnodeparent= vartree nodeparent.on("expand",function(pnode){ this, single createWin: function(winId,winTitle,iframePage,closeFun){//var =if win :title - +width height modal+ +=;}curFormWin=returnreloadNavNode function() :function()}}} 96.NavTree ;;varremoveFlag vartitleChangeFlag=varvarreturninit Ext.Msg.alert("NavTree.setMgr() = url loader.on('beforeload',ams= { :method } "text }=new title width autoScroll: animate loader root enableDD: listeners: 'click'function(node,event) (node.isLeaf()) 為葉子節(jié)點時,點擊不進入 ",s.showTree 件 nav.on("textchange",tion(node,newText,oldText) iflag newText oldText) dateTitle(node.id,newText,function(success) (!success)
title: msg: buttons:Ext.Msg.OK,icon titleChangeFlag=titleChangeFlag= 件 nav.on("movenode",on(tree,node,oldParent,nerent,index) ode.id,oldParent.id,nerent.id, 件 nav.on("remove",(tree,parentNode,node) if{ }}navEditor {allowBlank: ignoreNoChange blankText: selectOnFocus this.setLeaf setMgr = getMgr return : = .items text handlerfunction() },"- text handlerfunction() }"- text":t setDir: 設 菜if(!dirdir= items text handlerfunction() },"- text handlerfunction() },"- text handlerfunction() },"- text 添 節(jié)點 handlerfunction() },"- text handler showTree:function(node,nodeSelected (node.isLeaf()) }{ }firm Ext.Msg.confirm("確認刪除",{ { delTreeItem: (nodeSelected!= Node()){removeFlag removeFlag elseExt.Msg.alert("警告",}show //Ext.BLANK_IMAGE_URL="../scripts/ext/resources/Ext.Msg.alert("DWR,并NavigateManager");}dwrXml<?xmlversion=
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年4月重慶市婦幼保健院部分崗位招聘考前自測高頻考點模擬試題及完整答案詳解1套
- 2025年新疆職中語文試卷及答案
- 2025年如皋生物中考試題及答案
- 2025年濰坊市寒亭區(qū)人民檢察院公開招聘工作人員筆試模擬試卷有答案詳解
- 彼得潘課件教學課件
- 2025江蘇徐州幼兒師范高等??茖W校招聘教師12人模擬試卷及答案詳解(有一套)
- 硬鋁合金課件
- 媒體產品用戶反饋處理流程
- 滑坡安全課件
- 2025北京市規(guī)劃和自然資源委員會事業(yè)單位招聘工作人員55人模擬試卷帶答案詳解
- 2025-2030兒童財商培養(yǎng)納入早期智力開發(fā)體系的社會接受度調研
- 2025內蒙古呼和浩特市總工會工會社會工作者、專職集體協商指導員招聘29人備考考試題庫附答案解析
- 2025年全國保密教育線上培訓考試題及答案
- 2025年長春吉潤凈月醫(yī)院社會招聘模擬試卷(含答案詳解)
- 2025年國網寧夏電力有限公司高校畢業(yè)生提前批招聘校園宣講安排筆試參考題庫附帶答案詳解
- 零工經濟中的女性勞動者權益保障研究
- 2025年哈爾濱呼蘭區(qū)招聘禁毒協管員30人考試參考試題及答案解析
- 2025初級注冊安全工程師題庫合集(+答案)
- 2025年武漢東西湖分局招聘警務輔助人員招聘73人考試參考試題及答案解析
- 小學數學人教版(2024)三年級上第三單元毫米、分米和千米測試卷(含答案)
- 聚酰亞胺行業(yè)市場現狀分析報告
評論
0/150
提交評論