Combining jquery's dialog and Ztree to implement the steps

Source: Internet
Author: User
Tags json prepare
First prepare juqury-ui, Ztree js files and CSS files, the next step Xiang see this article hope to help you

The first step: First prepare Juqury-ui, Ztree js files and CSS files
Step two: Write in example.jsp file code

Copy Code code as follows:


.. Introduction of jQueryUI, Ztree js and css file


<body>


<button value= "Click on the Dialog dialog box of the pop-up tree" onclick = "gettree ()"/>


<div id= "Ztree" class= ztree "/>"


</body>


<script type= "Text/javascript" >


function Gettree () {


var url = "<c:url value= ' xx.html '/>";


var setting={


};


var znodes =[];


var option={


width:200,


hight:300


};


$.ajax ({


Url:url,


success:function (data) {


$.each (data,funtion (n,d) {


Znode.push ({


Id:d.id,


Name:d.name,


Pid:d.pid


})


});


$.fn.init.ztree (' #ztree '), Setting,znode);


$ (' #ztree '). dialog (option);


}


})


}


</script>


Step three: Provide data backstage

Copy Code code as follows:


@RequestMapping ("/zone_ajaxtree")


@ResponseBody


public list<zonebody> Zone_ajaxtree () {


list<zonebody> zones = Zonebodyservice.getzone_ajax ();


return zones;


}


Because to use the @responsebody, to introduce Jackson-core-asl-1.8.7.jar and Jackson-mapper-asl-1.8.7.jar, there is code in the Mvc.xml file:

Copy Code code as follows:


<bean
class= "Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
<property name= "Webbindinginitializer" >
<bean class= "Com.building.controller.BindingInitializer" />//here for user-defined
</property>
<property name= "Messageconverters" >
<ref bean= " Jsonhttpmessageconverter "/>//here provides JSON support for @responsebody
</property>
</bean>
<bean id= "Jsonhttpmessageconverter"
class= " Org.springframework.http.converter.json.MappingJacksonHttpMessageConverter "/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.