treeview_ checkbox中选择的js代码 和 层移动代码...
时间:2010-08-09 来源:benbenchong_ok
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PlanSet_ItemSet_Product.aspx.cs" Inherits="PMApp.DataManagement.ConfigManagement.PlanSet_ItemSet_Product" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="javascript" src="../../Javascript/IframeSetResize_2.js"></script>
<script type="text/javascript">
function postBackByObject() {
var o = window.event.srcElement;
if (o.tagName == "INPUT" && o.type == "checkbox") {
__doPostBack("UP_TreeView", "");
}
}
</script>
<script>
function public_GetParentByTagName(element, tagName)
{
var parent = element.parentNode;
var upperTagName = tagName.toUpperCase();
while (parent && (parent.tagName.toUpperCase() != upperTagName))
{
parent = parent.parentNode ? parent.parentNode : parent.parentElement;
}
return parent;
}
function setParentChecked(objNode)
{
var objParentDiv = public_GetParentByTagName(objNode,"div");
if(objParentDiv==null || objParentDiv == "undefined")
{
return;
}
var objID = objParentDiv.getAttribute("ID");
objID = objID.substring(0,objID.indexOf("Nodes"));
objID = objID+"CheckBox";
var objParentCheckBox = document.getElementById(objID);
if(objParentCheckBox==null || objParentCheckBox == "undefined")
{
return;
}
if(objParentCheckBox.tagName!="INPUT" && objParentCheckBox.type == "checkbox")
return;
objParentCheckBox.checked = true;
setParentChecked(objParentCheckBox);
}
function setChildUnChecked(divID)
{
var objchild = divID.children;
var count = objchild.length;
for(var i=0;i<objchild.length;i++)
{
var tempObj = objchild[i];
if(tempObj.tagName=="INPUT" && tempObj.type == "checkbox")
{
tempObj.checked = false;
}
setChildUnChecked(tempObj);
}
}
function setChildChecked(divID)
{
var objchild = divID.children;
var count = objchild.length;
for(var i=0;i<objchild.length;i++)
{
var tempObj = objchild[i];
if(tempObj.tagName=="INPUT" && tempObj.type == "checkbox")
{
tempObj.checked = true;
}
setChildChecked(tempObj);
}
}
//触发事件
function CheckEvent()
{
var objNode = event.srcElement;
if(objNode.tagName!="INPUT" || objNode.type!="checkbox")
return;
if(objNode.checked==true)
{
setParentChecked(objNode);
var objID = objNode.getAttribute("ID");
var objID = objID.substring(0,objID.indexOf("CheckBox"));
var objParentDiv = document.getElementById(objID+"Nodes");
if(objParentDiv==null || objParentDiv == "undefined")
{
return;
}
setChildChecked(objParentDiv);
}
else
{
var objID = objNode.getAttribute("ID");
var objID = objID.substring(0,objID.indexOf("CheckBox"));
var objParentDiv = document.getElementById(objID+"Nodes");
if(objParentDiv==null || objParentDiv == "undefined")
{
return;
}
setChildUnChecked(objParentDiv);
}
}
</script>
<script type="text/javascript" language="javascript">
function show(checkbox_list) {
var checkbox_list = document.getElementById(checkbox_list);
checkbox_list.style.display = "block";
}
function hidden(checkbox_list) {
var checkbox_list = document.getElementById(checkbox_list);
checkbox_list.style.display = "none";
}
</script>
<style type="text/css">
body
{
filter: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#ffffff,endColorStr=#ffffff);
}
#massage_box
{
position: absolute;
left: expression((body.clientWidth-350)/2);
top: expression((body.clientHeight-200)/2);
width: 350px;
filter: dropshadow(color=#666666,offx=3,offy=3,positive=2);
z-index: 2;
visibility: hidden;
}
#mask
{
position: absolute;
top: 0;
left: 0;
width: expression(body.scrollWidth);
background: #ffffff;
filter: ALPHA(opacity=60);
z-index: 1;
visibility: hidden;
}
.massage
{
border: #036 solid;
border-width: 1 1 3 1;
width: 95%;
background: #fff;
color: #036;
font-size: 12px;
line-
overflow:scroll;
}
.header
{
background: #036;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
padding: 3 5 0 5;
color: #fff;
}
</style>
<!--实现层移动-->
<script type="text/javascript">
var Obj = ''
document.onmouseup = MUp
document.onmousemove = MMove
function MDown(Object) {
Obj = Object.id
document.all(Obj).setCapture()
pX = event.x - document.all(Obj).style.pixelLeft;
pY = event.y - document.all(Obj).style.pixelTop;
}
function MMove() {
if (Obj != '') {
document.all(Obj).style.left = event.x - pX;
document.all(Obj).style.top = event.y - pY;
}
}
function MUp() {
if (Obj != '') {
document.all(Obj).releaseCapture();
Obj = '';
}
}
</script>
<!--弹出对话框-->
<script language="javascript">
function openlimsprdctSelect(itemid, ConfigID, type) {
var returnValue = window.showModalDialog('TreeShow.aspx?itemid='+ itemid + '&pid=2&ConfigID=' + ConfigID + '&type=' + type + '', window, 'dialogWidth=350px;dialogHeight=500px;resizable:yes;scroll:yes');
if (returnValue != undefined)
this.location = this.location;
// window.event.srcElement.value = returnValue;
}
</script>
<script type="text/javascript" language="javascript">
function refresh() {
this.location = this.location; //刷新
}
</script>
</head>
<body>
<form id="form2" runat="server">
<br />
<asp:Panel runat="server" Visible="false">
<table class="info" align="center">
<tr>
<td align="center" style="width: 20%;" class="info-Title">
当前配置报表:
</td>
<td align="left" style="width: 40%;" class="">
炼油产品计划上报表
</td>
<td align="left" style="color: silver;" class="info-Title">
*当前配置的报表
</td>
</tr>
<tr>
<td align="center" style="width: 20%;" class="info-Title">
选择配置项目:
</td>
<td align="left" style="width: 40%;" class="info-Title">
<asp:DropDownList ID="ddrSelectCate" runat="server" AutoPostBack="true" Width="150px"
OnSelectedIndexChanged="ddrSelectCate_SelectedIndexChanged">
</asp:DropDownList>
<asp:Label ID="lblSign" runat="server" Visible="false"></asp:Label>
</td>
<td align="left" style="color: silver;" class="info-Title">
*选择某一具体的配置项目
</td>
</tr>
</table>
<br />
<table width="95%" align="center">
<tr>
<td style="width: 40%;" class="info-Title">
供选产品:
</td>
<td>
</td>
<td style="width: 40%;" class="info-Title">
已选产品:
</td>
</tr>
</table>
<table align="center" width="95%">
<tr>
<td valign="top" width="40%" style="
<asp:TreeView ID="TreeProduct" runat="server" ExpandDepth="1"
CssClass="treeView" Font-Size="10pt" ShowLines="True"
onclick="client_OnTreeNodeChecked();" ShowCheckBoxes="All" Width="156px"
ontreenodecheckchanged="TreeProduct_TreeNodeCheckChanged">
</asp:TreeView>
</td>
<td align="center">
<asp:Button ID="btnSelect" runat="server" Text="==>>" class="FlatButton" OnClick="btnSelect_Click" />
<br />
<br />
<asp:Button ID="btnUnselect" runat="server" Text="<<==" class="FlatButton" OnClick="btnUnselect_Click" />
</td>
<td valign="top" width="40%" style="
<asp:TreeView ID="TreeProduct2" runat="server" ExpandDepth="1"
CssClass="treeView" Font-Size="10pt" ShowLines="True" ShowCheckBoxes="All"
onclick="client_OnTreeNodeChecked();" Width="156px" onselectednodechanged="TreeProduct2_SelectedNodeChanged"
ontreenodecheckchanged="TreeProduct2_TreeNodeCheckChanged">
</asp:TreeView>
</td>
</tr>
</table>
<table width="95%" align="center">
<tr>
<td style="width: 40%">
</td>
<td>
<%--<input id="Button1" type="button" value="保存" class="FlatButton" />--%>
<asp:Button ID="btnPreview" runat="server" CssClass="FlatButton" Text="预 览"
onclick="btnPreview_Click" />
<%--<input id="Button2" type="button" value="预览" class="FlatButton" />--%>
<asp:Button ID="btnReturn" runat="server" CssClass="FlatButton" Text="确 定"
onclick="btnReturn_Click" />
</td>
</tr>
</table>
</asp:Panel>
<table style="width: 100%;" class="info" align="center">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="添加" OnClick="Button1_Click" Visible="false" />
<input type="button" value="添加" onclick="openlimsprdctSelect('LYCP','<%=ConfigID %>','1')"/>
<!--div begin-->
<div id="checkbox_sizemodellist" style="display: none; z-index: 2000; position: static;
left: 60px; top: 23px; border: 0px solid #06c; padding: 0px; background: #F8F8FF;
width: 65%;" visible="false">
<div style="background: #F0F0F0; text-align: right; padding-right: 3px;">
<span style="width: 12; border-width: 1px; color: Maroon; font-family: webdings;
cursor: hand; left: -200;" onclick="hidden('checkbox_sizemodellist')">r</span>
</div>
<asp:PlaceHolder ID="phl" runat="server"></asp:PlaceHolder>
<asp:Panel ID="PanelInfo" runat="server" CssClass="panel" GroupingText="配置项">
<table class="lablestyle">
<tr>
<td class="lblStyle">
<asp:Label ID="lblStyleProductID" runat="server" Text="项目编码:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlOilCode" runat="server" CssClass="txtBox" Width="125">
</asp:DropDownList>
</td>
<td class="lblStyle">
</td>
<td class="lblStyle">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td class="lblStyle">
<asp:Label ID="lblStyleRemark" runat="server" Text="备注:"></asp:Label>
</td>
<td colspan="5">
<asp:TextBox ID="tbRemark" runat="server" CssClass="txtBox" Width="120"></asp:TextBox>
</td>
</tr>
<tr>
<td class="lblStyle">
序号:
</td>
<td colspan="5">
<asp:TextBox ID="tbsort" runat="server" CssClass="txtBox" Width="120"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="6">
<asp:Button ID="btnSubmit" runat="server" CssClass="buttonstyle" OnClick="btnSubmit_Click"
Text="提交" />
<input name="" class="button" type="button" onclick="hidden('checkbox_sizemodellist')"
value="关闭" style="width: 40px;" /><br />
</td>
</tr>
</table>
</asp:Panel>
</div>
<!--div end-->
<!--div start-->
<div id="massage_box">
<div class="massage">
<div class="header" onmousedown="MDown(massage_box)">
<div style="display: inline; width: 150px; position: absolute; "> 详细信息</div>
<span onclick="massage_box.style.visibility='hidden'; mask.style.visibility='hidden'" style="float: right; display: inline; cursor: hand; font-size:medium; font-weight:bold;" >×</span>
<br />
<div>
<ul style="margin-right: 25;">
<asp:TreeView ID="TreeProduct3" runat="server" ExpandDepth="1"
CssClass="treeView" Font-Size="10pt" ShowLines="false"
onclick="client_OnTreeNodeChecked();" ShowCheckBoxes="All" Width="156px"
ontreenodecheckchanged="TreeProduct_TreeNodeCheckChanged">
</asp:TreeView>
</ul>
<center>
<asp:Button ID="Button3" Text="添加" runat="server" OnClick="Button3_Click"/>
</center>
</div>
</div>
</div>
</div>
<div id="mask">
</div>
<span onclick="mask.style.visibility='visible';massage_box.style.visibility='visible'" style="cursor: hand">
<a href="#" runat="server" id="htmla" visible="false">树形添加 </a></span>
<!--div end-->
<asp:Label ID="lblsign2" runat="server" Visible="False"></asp:Label>
<asp:GridView ID="GridView1" Width="70%" runat="server" AutoGenerateColumns="False"
OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDeleting="GridView1_RowDeleting"
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowDataBound="GridView1_RowDataBound"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3" DataKeyNames="itemid" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
OnRowCommand="GridView1_RowCommand">
<RowStyle ForeColor="#000066" />
<Columns>
<asp:TemplateField HeaderText="编码">
<ItemStyle HorizontalAlign="Center" Width="9%" />
<ItemTemplate>
<%# Eval("itemid")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="项目名称">
<EditItemTemplate>
<asp:TextBox ID="txt_name" Text='<%# DataBinder.Eval(Container,"DataItem.ITEMNAME") %>'
runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lab_name" Text='<%# DataBinder.Eval(Container,"DataItem.ITEMNAME") %>'
runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="备注">
<EditItemTemplate>
<asp:TextBox ID="txt_remark" Text='<%# DataBinder.Eval(Container,"DataItem.remark") %>'
runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lab_remark" Text='<%# DataBinder.Eval(Container,"DataItem.remark") %>'
runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="center" Width="14%"/>
</asp:TemplateField>
<asp:TemplateField HeaderText="排列顺序">
<ItemStyle HorizontalAlign="Center" Width="14%" />
<EditItemTemplate>
<asp:TextBox ID="txt_sort" Text='<%# DataBinder.Eval(Container,"DataItem.sort_no") %>'
runat="server" Width="50%"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lab_sort" Text='<%# DataBinder.Eval(Container,"DataItem.sort_no") %>'
runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ITEMID" Visible="False">
<ItemTemplate>
<asp:Label ID="lab_id" Text='<%# DataBinder.Eval(Container,"DataItem.ITEMID") %>'
runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CONFID" Visible="False">
<ItemTemplate>
<asp:Label ID="lab_confid" Text='<%# DataBinder.Eval(Container,"DataItem.CONFID") %>'
runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True">
<ItemStyle HorizontalAlign="Center" Width="15%" />
</asp:CommandField>
<asp:TemplateField ShowHeader="False">
<ItemStyle HorizontalAlign="Center" Width="9%" />
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="return confirm('确定要删除吗?')"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle Width="8%" HorizontalAlign="Center" />
<ItemTemplate>
<asp:Button ID="Button2" runat="server" Text="添加" CommandArgument='<%# Eval("ITEMID") %>'
CommandName="add" Visible="false"/>
<a href="#" onclick="openlimsprdctSelect('<%# Eval("ITEMID") %>','<%=ConfigID %>','2')">添加</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</td>
</tr>
</table>
</form>
</body>
</html>
后台:this.TreeProduct.Attributes.Add("onclick", "CheckEvent()");