求一个用asp.net左边显示功能树,右边动态显示子窗体的简单例子.最好有源码,江湖救急!
1个回答
展开全部
<link type="text/css" rel="stylesheet" href="../../Content/zTreeStyle.css" />
<link type="text/css" rel="stylesheet" href="/resource/css/smoothness/jquery-ui-1.7.custom.css" />
<script type="text/javascript" src="../../Scripts/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript">
$(function () {
BindTree();
})
function BindGrid(pageIndex) {
var sort = "";
if ($("#sortname").val() != "") {
if ($("#sortdesc").val() != "1") {
sort = $("#sortname").val() + " desc";
}
else {
sort = $("#sortname").val() + " asc";
}
}
pageIndex = parseInt(pageIndex);
$("#pageIndex").val(pageIndex);
var pageSize = $("#page_limit").val();
if (pageSize == undefined)
pageSize = 20;
$.ajax({
type: "POST",
url: "/YiXin/GetYXSysCodeById",
data: {
parentId: $("#sysCode").val(), pageIndex: pageIndex, pageSize: pageSize, sort: sort
},
dataType: "json",
error: function (e)//出错处理
{
ErrAlert(e, "获取列表失败!");
},
success: function (data) {
BindContent(data);
BindPage(pageSize, pageIndex, data.TotalPage, data.TotalRecord);
}
});
}
//生成内容
function BindContent(data) {
var str = "";
for (var o in data.ListView) {
str += "<tr align='center'>";
str += "<td align=\"center\"><a href=\"javascript:void(0)\" onclick=\"showEdit('" + data.ListView[o].GID + "','编辑')\">编辑</a> ";
//str += "<a href=\"javascript:void(0)\" onclick=\"showCategory('" + data.ListView[o].GID + "','" + data.ListView[o].Categories + "','栏目')\">子栏目</a> ";
//str += "<a href='/NewsInfo/CommendList/?newsinfoid=" + data.ListView[o].GID + "'>评论</a> ";
// str += "<a href=\"javascript:void(0)\" onclick=\"DelSysCode('" + data.ListView[o].GID + "')\">删除</a>";
str += "</td>";
str += "<td> " + data.ListView[o].Code + "</td>";
str += "<td> " + data.ListView[o].GroupCode + "</td>";
str += "<td> " + data.ListView[o].Name + "</td>";
str += "<td> " + data.ListView[o].Remark + "</td>";
str += "<td><input id='" + data.ListView[o].GID + "' type='checkbox' " + (data.ListView[o].IsShow ? "checked" : "") + " value='" + (data.ListView[o].IsShow ? true : false) + "' onclick='SetEnable(this)'/></td>";
str += "</tr>";
}
$("#main_table tbody").html(str);
return str;
}
function BindPage(pageSize, pageIndex, totalPage, totalRecord) {
if (pageIndex >= totalPage)
pageIndex = totalPage - 1;
var str = "<div style=\"float:left;width:205px\">";
str += "<table>";
str += "<tr><td >";
str += "<select class=\"span2\" id=\"page_limit\" onchange=\"BindGrid(0)\"> ";
str += "<option value=\"10\" ";
if (pageSize == 10) {
str += " selected ";
}
str += ">每页10个</option>";
str += "<option value=\"20\" ";
if (pageSize == 20) {
str += " selected ";
}
str += ">每页20个</option>";
str += "<option value=\"50\" ";
if (pageSize == 50) {
str += " selected ";
}
str += ">每页50个</option>";
str += "</select>";
str += "</td >";
str += "<td><input type=\"text\" id=\"jumto_page\" value=" + parseInt(pageIndex + 1) + " style=\"width:20px\" onkeydown=\"OnKeyDown()\" onchange=\"SelectValue()\"/></td><td>/</td>";
str += "<td>";
str += " <div id=\"totlePagediv\">" + totalPage + " Total:" + totalRecord + "</div>";
str += " </td>";
str += " </tr>";
str += " </table>";
str += " </div>";
str += " <div id=\"nextdiv\" style=\"width:200px;text-align:right;float:right\">";
if (pageIndex > 0) {
str += "<a id=\"button_pre\" href=\"javascript:void(0);\"onclick=\"BindGrid(" + parseInt(pageIndex - 1) + ")\">Pre </a> ";
}
else {
str += " Pre ";
}
if (pageIndex + 1 != totalPage && totalPage != 0) {
str += " <a id=\"button_next\" href=\"javascript:void(0);\" onclick=\"BindGrid(" + parseInt(pageIndex + 1) + ")\">Next</a>";
}
else {
str += " Next";
}
str += " </div>";
$("#divPage").html(str);
}
function OnKeyDown() {
if (event.keyCode == 13) {
SelectValue();
}
}
function SelectValue() {
var txt = $("#jumto_page").val();;
if (!isInteger(txt)) {
alert("只允许输入正整数!");
}
else {
BindGrid(parseInt(txt) - 1);
}
}
function SortTable(name) {
if ($("#sortname").val() == name) {
if ($("#sortdesc").val() == "1") {
$("#sortdesc").val("0");
}
else {
$("#sortdesc").val("1");
}
}
else {
$("#sortname").val(name);
$("#sortdesc").val("0");
}
BindGrid(0);
}
function Search() {
BindGrid(0);
}
</script>
<SCRIPT type="text/javascript">
<!--
var setting = {
data: {
key: {
title: ""
},
simpleData: {
enable: true
}
},
callback: {
beforeClick: beforeClick,
onClick: onClick
}
};
function beforeClick(treeId, treeNode, clickFlag) {
return (treeNode.click != false);
}
function onClick(event, treeId, treeNode, clickFlag) {
$("#a_import_record").attr("Disabled", false);
// $("#btnSearch").attr("Disabled", false);
var parentId = treeNode.id;
var parentNane = treeNode.name
//if (parentcode == "syscode")
// parentcode = "";
getCodeList(parentId, parentNane);
}
function getCodeList(parentcode, syscodename) {
$("#sysCode").val(parentcode);
$("#sysCodeName").val(syscodename);
BindGrid(0);
//todo:获取新闻列表
}
function BindTree() {
$.ajax({
type: "POST",
url: "/YiXin/GetYXSysCodeTree",
dataType: "json",
error: function (e)//出错处理
{
alert("程序出错!");
},
success: function (data)//成功处理
{
$.fn.zTree.init($("#treeDemo"), setting, data);
}
});
}
//-->
</SCRIPT>
<input type="hidden" id="sysCode" value="" />
<input type="hidden" id="sysCodeName" value="" />
<input type="hidden" id="sortname" value="" />@*记录排序字段*@
<input type="hidden" id="sortdesc" />@*记录排序字段的升降 0表示升序 1表示降序*@
<input type="hidden" id="pageIndex" name="pageIndex" value="0" />
<table width="100%" id="main" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top">
<!-- layout main right 中心显示区之主要内容显示区域 -->
<div id="main_content1">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="235px" valign="top" style="padding: 0 4px">
<dl style="border: solid 1px #ccc; border-bottom: solid 1px #eee; margin: 0 0 0 0;">
<dd style="clear: both; padding: 0px 5px 5px 0px; display: block">
<ul id="treeDemo" class="ztree" style="overflow: auto; height: 480px; width: 220px; padding-top: 5px; position: relative">
</ul>
</dd>
</dl>
</td>
<td valign="top" style="padding: 0 4px">
<div id="main_content">
<table width="100%" id="main_table" class="table table-striped table-bordered bootstrap-datatable datatable">
<caption>
<div id="button_search" class="form-horizontal" style="text-align: left; border: solid 1px #ccc; background: #eee; padding: 20px 0 5px 5px; margin: 0 0 0 0; display: block">
<input id="a_import_record" type="button" class="btn btn-primary" value="新增" onclick="showEdit('', '新增')" disabled />
</div>
<div id="searchBox" style="text-align: left; width: 100px; float: left; padding-top: 20px; display: none">
<a href="javascript:void(0)">搜索</a>
</div>
</caption>
<thead>
<tr>
<th width="100px" align="center">管理</th>
<th width="100px" align="center">代码</th>
<th width="100px" align="center">分组代码</th>
<th width="200px" align="center">名称</th>
<th width="200px" align="center">备注</th>
<th width="80px" align="center">启用</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div style="margin-top: 6px" id="divPage">
</div>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
更多追问追答
追问
能把项目直接发我q上吗,万分感谢,387678633
追答
我这个项目是MVC的,不知道你是webform的还是MVC的,项目是不能发给你的,这个你懂得.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询