Combine the dialog and ztree of jquery to achieve the steps _jquery

Source: Internet
Author: User
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 files
<body>
<button value= "Click 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 "/>//this is customized for users
</property>
<property name= "Messageconverters" >
<ref bean= "Jsonhttpmessageconverter"/>// This provides JSON support for @responsebody
</property>
</bean>
<bean id= "Jsonhttpmessageconverter"
C lass= "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.