zoukankan      html  css  js  c++  java
  • ReportViewer2010冻结行列

     1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewTrackingVer.aspx.cs"
     2     Inherits="GeoOilRes.RDLC.NewTrackingVer" %>
     3 
     4 <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
     5     Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
     6 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     7 <html xmlns="http://www.w3.org/1999/xhtml">
     8 <head id="Head1" runat="server">
     9     <title></title>
    10     <script src="../../Scripts/jquery-1.8.1.min.js" type="text/javascript"></script>
    11     <script src="../Scripts/rdlc-function.js" type="text/javascript"></script>
    12     <script type="text/javascript">
    13            $(function () {
    14             var ReportTable = $('#VisibleReportContentReportViewer1_ctl10');
    15             if (ReportTable.html().length > 0 ) {
    16                 var w = pageWidth();
    17                 var h = pageHeight();
    18                 var tableID = "RdlcTable";
    19                 $('#VisibleReportContentReportViewer1_ctl10 table table table table:last').attr("ID", tableID);
    20                 freezeTable(tableID, 5, 4, w, h);
    21                 var flag = false;
    22                 $(window).resize(function () {
    23                     if (flag)
    24                         return;
    25                     setTimeout(function () {
    26                         adjustTableSize(tableID, w, h);
    27                         flag = false;
    28                     }, 100);
    29                     flag = true;
    30                 });
    31             }
    32         });
    33 </script>
    34 </head>
    35 <body style="padding: 0; margin: 0; overflow: hidden; background-color: white;">
    36     <form id="form1" runat="server" style="text-align: left;">
    37     <asp:ScriptManager ID="ScriptManager1" runat="server">
    38     </asp:ScriptManager>           <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline">
    39         <ContentTemplate>
    40             <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
    41                 InteractiveDeviceInfos="(集合)" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"
    42                 Width="100%" Height="100%" ShowToolBar="true" ShowBackButton="False" ShowFindControls="False"
    43                 ShowRefreshButton="False" HyperlinkTarget="_self">
    44             </rsweb:ReportViewer>
    45         </ContentTemplate>
    46         <Triggers>
    47             <asp:PostBackTrigger ControlID="ReportViewer1" />
    48         </Triggers>
    49     </asp:UpdatePanel>
    50     </form>
    51     </body>
    52 </html>
      1 /*
      2 * 锁定表头和列
      3 * 
      4 * 参数定义
      5 *     table - 要锁定的表格元素或者表格ID
      6 *     freezeRowNum - 要锁定的前几行行数,如果行不锁定,则设置为0
      7 *     freezeColumnNum - 要锁定的前几列列数,如果列不锁定,则设置为0
      8 *     width - 表格的滚动区域宽度
      9 *     height - 表格的滚动区域高度
     10 */
     11 function freezeTable(table, freezeRowNum, freezeColumnNum, width, height) {
     12     freezeRowNum += 1;
     13     freezeColumnNum += 1;
     14     if (typeof (freezeRowNum) == 'string')
     15         freezeRowNum = parseInt(freezeRowNum)
     16 
     17     if (typeof (freezeColumnNum) == 'string')
     18         freezeColumnNum = parseInt(freezeColumnNum)
     19 
     20     var tableId;
     21     if (typeof (table) == 'string') {
     22         tableId = table;
     23         table = $('#' + tableId);
     24     } else
     25         tableId = table.attr('id');
     26 
     27     var divTableLayout = $("#" + tableId + "_tableLayout");
     28 
     29     if (divTableLayout.length != 0) {
     30         divTableLayout.before(table);
     31         divTableLayout.empty();
     32     } else {
     33         table.after("<div id='" + tableId + "_tableLayout' style='overflow:hidden;height:" + height + "px; " + width + "px;'></div>");
     34 
     35         divTableLayout = $("#" + tableId + "_tableLayout");
     36     }
     37 
     38     var html = '';
     39     if (freezeRowNum > 0 && freezeColumnNum > 0)
     40         html += '<div id="' + tableId + '_tableFix" style="padding: 0px;"></div>';
     41 
     42     if (freezeRowNum > 0)
     43         html += '<div id="' + tableId + '_tableHead" style="padding: 0px;"></div>';
     44 
     45     if (freezeColumnNum > 0)
     46         html += '<div id="' + tableId + '_tableColumn" style="padding: 0px;"></div>';
     47 
     48     html += '<div id="' + tableId + '_tableData" style="padding: 0px;"></div>';
     49 
     50 
     51     $(html).appendTo("#" + tableId + "_tableLayout");
     52 
     53     var divTableFix = freezeRowNum > 0 && freezeColumnNum > 0 ? $("#" + tableId + "_tableFix") : null;
     54     var divTableHead = freezeRowNum > 0 ? $("#" + tableId + "_tableHead") : null;
     55     var divTableColumn = freezeColumnNum > 0 ? $("#" + tableId + "_tableColumn") : null;
     56     var divTableData = $("#" + tableId + "_tableData");
     57 
     58     divTableData.append(table);
     59 
     60     if (divTableFix != null) {
     61         var tableFixClone = table.clone(true);
     62         tableFixClone.attr("id", tableId + "_tableFixClone");
     63         divTableFix.append(tableFixClone);
     64     }
     65 
     66     if (divTableHead != null) {
     67         var tableHeadClone = table.clone(true);
     68         tableHeadClone.attr("id", tableId + "_tableHeadClone");
     69         divTableHead.append(tableHeadClone);
     70     }
     71 
     72     if (divTableColumn != null) {
     73         var tableColumnClone = table.clone(true);
     74         tableColumnClone.attr("id", tableId + "_tableColumnClone");
     75         divTableColumn.append(tableColumnClone);
     76     }
     77 
     78     $("#" + tableId + "_tableLayout table").css("margin", "0");
     79 
     80     if (freezeRowNum > 0) {
     81         var HeadHeight = 0;
     82         var ignoreRowNum = 0;
     83         $("#" + tableId + "_tableHead tr:lt(" + freezeRowNum + ")").each(function () {
     84             if (ignoreRowNum > 0)
     85                 ignoreRowNum--;
     86             else {
     87                 var td = $(this).find('td:first, th:first');
     88                 HeadHeight += td.outerHeight(true);
     89 
     90                 ignoreRowNum = td.attr('rowSpan');
     91                 if (typeof (ignoreRowNum) == 'undefined')
     92                     ignoreRowNum = 0;
     93                 else
     94                     ignoreRowNum = parseInt(ignoreRowNum) - 1;
     95             }
     96         });
     97         HeadHeight += 2;
     98 
     99         divTableHead.css("height", HeadHeight);
    100         divTableFix != null && divTableFix.css("height", HeadHeight);
    101     }
    102 
    103     if (freezeColumnNum > 0) {
    104         var ColumnsWidth = 0;
    105         var ColumnsNumber = 0;
    106         $("#" + tableId + "_tableColumn tr:eq(" + freezeRowNum + ")").find("td:lt(" + freezeColumnNum + "), th:lt(" + freezeColumnNum + ")").each(function () {
    107             if (ColumnsNumber >= freezeColumnNum)
    108                 return;
    109 
    110             ColumnsWidth += $(this).outerWidth(true);
    111 
    112             ColumnsNumber += $(this).attr('colSpan') ? parseInt($(this).attr('colSpan')) : 1;
    113         });
    114         ColumnsWidth += 2;
    115 
    116         divTableColumn.css("width", ColumnsWidth);
    117         divTableFix != null && divTableFix.css("width", ColumnsWidth);
    118     }
    119 
    120     divTableData.scroll(function () {
    121         divTableHead != null && divTableHead.scrollLeft(divTableData.scrollLeft());
    122 
    123         divTableColumn != null && divTableColumn.scrollTop(divTableData.scrollTop());
    124     });
    125 
    126     divTableFix != null && divTableFix.css({ "overflow": "hidden", "background-color": "white", "position": "absolute", "z-index": "50" });
    127     divTableHead != null && divTableHead.css({ "overflow": "hidden", "background-color": "white", "width": width - 17, "position": "absolute", "z-index": "45" });
    128     divTableColumn != null && divTableColumn.css({ "overflow": "hidden", "background-color": "white", "height": height - 17, "position": "absolute", "z-index": "40" });
    129     divTableData.css({ "overflow": "scroll", "width": width, "height": height, "position": "absolute" });
    130 
    131     divTableFix != null && divTableFix.offset(divTableLayout.offset());
    132     divTableHead != null && divTableHead.offset(divTableLayout.offset());
    133     divTableColumn != null && divTableColumn.offset(divTableLayout.offset());
    134     divTableData.offset(divTableLayout.offset());
    135 }
    136 
    137 /*
    138 * 调整锁定表的宽度和高度,这个函数在resize事件中调用
    139 * 
    140 * 参数定义
    141 *     table - 要锁定的表格元素或者表格ID
    142 *     width - 表格的滚动区域宽度
    143 *     height - 表格的滚动区域高度
    144 */
    145 function adjustTableSize(table, width, height) {
    146     var tableId;
    147     if (typeof (table) == 'string')
    148         tableId = table;
    149     else
    150         tableId = table.attr('id');
    151 
    152     $("#" + tableId + "_tableLayout").width(width).height(height);
    153     $("#" + tableId + "_tableHead").width(width - 17);
    154     $("#" + tableId + "_tableColumn").height(height - 17);
    155     $("#" + tableId + "_tableData").width(width).height(height);
    156 }
    157 
    158 function pageHeight() {
    159     if ($.browser.msie) {
    160         return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
    161     } else {
    162         return self.innerHeight;
    163     }
    164 };
    165 
    166 //返回当前页面宽度
    167 function pageWidth() {
    168     if ($.browser.msie) {
    169         return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
    170     } else {
    171         return self.innerWidth;
    172     }
    173 };
  • 相关阅读:
    good array(数论+随机算法)
    triple balance(贪心+构造)
    树上拓扑排序(交互题)
    模数循环节
    string操作总结
    移除相邻(string操作+implement)
    二维树状数组(单点更新+区间查询)
    docker mysql Client does not support
    Docker 常见问题
    Linux安装 Docker
  • 原文地址:https://www.cnblogs.com/yuking/p/3686015.html
Copyright © 2011-2022 走看看