treeview_ checkbox中選擇的js代碼 和 層移動代碼

<%@ 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;
        height: 400px;
        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);
        height: expression(body.scrollHeight);
        background: #ffffff;
        filter: ALPHA(opacity=60);
        z-index: 1;
        visibility: hidden;
    }
    .massage
    {
        border: #036 solid;
        border-width: 1 1 3 1;
        width: 95%;
        height: 95%;
        background: #fff;
        color: #036;
        font-size: 12px;
        line-height: 150%;
         overflow:scroll;
    }
    .header
    {
        background: #036;
        height: 5%;
        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="height: 200px">
              
                <asp:TreeView ID="TreeProduct" runat="server" ExpandDepth="1" 
                    CssClass="treeView" Font-Size="10pt" ShowLines="True" 
                    οnclick="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="height: 200px">
            
                <asp:TreeView ID="TreeProduct2" runat="server" ExpandDepth="1" 
                    CssClass="treeView" Font-Size="10pt" ShowLines="True"  ShowCheckBoxes="All"
                    οnclick="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%">
                &nbsp;
            </td>
            <td>
                <%--<input id="Button1" type="button" value="保存" class="FlatButton" />--%>
                <asp:Button ID="btnPreview" runat="server" CssClass="FlatButton" Text="預  覽"
                    οnclick="btnPreview_Click" />
                &nbsp;
                <%--<input id="Button2" type="button" value="預覽" class="FlatButton" />--%>
                <asp:Button ID="btnReturn" runat="server" CssClass="FlatButton" Text="確  定"
                    οnclick="btnReturn_Click" />
            </td>
        </tr>
    </table>
    </asp:Panel>
     <table style="width: 100%;" class="info" align="center">
        <tr>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;<asp:Button ID="Button1" runat="server" Text="添加" OnClick="Button1_Click" Visible="false" />
                <input  type="button"  value="添加" οnclick="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; height: 2px; border-width: 1px; color: Maroon; font-family: webdings;
                            cursor: hand; left: -200;" οnclick="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="提交" />
                                    &nbsp;&nbsp;
                                    <input name="" class="button" type="button" οnclick="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" οnmοusedοwn="MDown(massage_box)">
                    <div style="display: inline; width: 150px; position: absolute; "> 詳細信息</div>
                    <span οnclick="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" 
                            οnclick="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 οnclick="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>
                                &nbsp;<asp:Button ID="Button2" runat="server" Text="添加" CommandArgument='<%# Eval("ITEMID") %>'
                                    CommandName="add"  Visible="false"/>
                                     <a href="#" οnclick="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()");

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章