您现在的位置是:网站首页> 编程资料编程资料
asp.net实现固定GridView标题栏的方法(冻结列功能)_实用技巧_
2023-05-24
312人已围观
简介 asp.net实现固定GridView标题栏的方法(冻结列功能)_实用技巧_
本文实例讲述了asp.net实现固定GridView标题栏的方法。分享给大家供大家参考,具体如下:
<%@ Page Language="C#" %><%@ Import Namespace="System.Data" %>
// Super Tables Plugin for jQuery - MIT Style License // Copyright (c) 2009 Jeffrey Lee --- blog.darkthread.net // // A wrapper for Matt Murphy's Super Tables http://www.matts411.com/post/super_tables/ // // Contributors: // ////// TO CALL: // $("...").toSuperTable(options) // ////// OPTIONS: (order does not matter ) // cssSkin : string ( eg. "sDefault", "sSky", "sOrange", "sDark" ) // headerRows : integer ( default is 1 ) // fixedCols : integer ( default is 0 ) // colWidths : integer array ( use -1 for auto sizing ) // onStart : function ( any this.variableNameHere variables you create here can be used later ( eg. onFinish function ) ) // onFinish : function ( all this.variableNameHere variables created in this script can be used in this function ) // margin, padding, width, height, overflow...: Styles for "fakeContainer" // ////// Example: // $("#GridView1").toSuperTable( // { width: "640px", height: "480px", fixedCols: 2, // onFinish: function() { alert('Done!'); } }) // jquery.superTable.js (function($) { $.fn.extend( { toSuperTable: function(options) { var setting = $.extend( { width: "640px", height: "320px", margin: "10px", padding: "0px", overflow: "hidden", colWidths: undefined, fixedCols: 0, headerRows: 1, onStart: function() { }, onFinish: function() { }, cssSkin: "sSky" }, options); return this.each(function() { var q = $(this); var id = q.attr("id"); q.removeAttr("style").wrap(""); var nonCssProps = ["fixedCols", "headerRows", "onStart", "onFinish", "cssSkin", "colWidths"]; var container = $("#" + id + "_box"); for (var p in setting) { if ($.inArray(p, nonCssProps) == -1) { container.css(p, setting[p]); delete setting[p]; } } var mySt = new superTable(id, setting); }); } }); })(jQuery); // Super Tables v0.30 - MIT Style License // Copyright (c) 2008 Matt Murphy --- www.matts411.com // // Contributors: // Joe Gallo ////// TO CALL: // new superTable([string] tableId, [object] options); // ////// OPTIONS: (order does not matter ) // cssSkin : string ( eg. "sDefault", "sSky", "sOrange", "sDark" ) // headerRows : integer ( default is 1 ) // fixedCols : integer ( default is 0 ) // colWidths : integer array ( use -1 for auto sizing ) // onStart : function ( any this.variableNameHere variables you create here can be used later ( eg. onFinish function ) ) // onFinish : function ( all this.variableNameHere variables created in this script can be used in this function ) // ////// EXAMPLES: // var myST = new superTable("myTableId"); // // var myST = new superTable("myTableId", { // cssSkin : "sDefault", // headerRows : 1, // fixedCols : 2, // colWidths : [100, 230, 220, -1, 120, -1, -1, 120], // onStart : function () { // this.start = new Date(); // }, // onFinish : function () { // alert("Finished... " + ((new Date()) - this.start) + "ms."); // } // }); // ////// ISSUES / NOTES: // 1. No quirksmode support (officially, but still should work) // 2. Element id's may be duplicated when fixedCols > 0, causing getElementById() issues // 3. Safari will render the header row incorrectly if the fixed header row count is 1 and there is a colspan > 1 in one // or more of the cells (fix available) ////////////superTables.js/////////// var superTable = function (tableId, options) { /////* Initialize */ options = options || {}; this.cssSkin = options.cssSkin || ""; this.headerRows = parseInt(options.headerRows || "1"); this.fixedCols = parseInt(options.fixedCols || "0"); this.colWidths = options.colWidths || []; this.initFunc = options.onStart || null; this.callbackFunc = options.onFinish || null; this.initFunc && this.initFunc(); /////* Create the framework dom */ this.sBase = document.createElement("DIV"); this.sFHeader = this.sBase.cloneNode(false); this.sHeader = this.sBase.cloneNode(false); this.sHeaderInner = this.sBase.cloneNode(false); this.sFData = this.sBase.cloneNode(false); this.sFDataInner = this.sBase.cloneNode(false); this.sData = this.sBase.cloneNode(false); this.sColGroup = document.createElement("COLGROUP"); this.sDataTable = document.getElementById(tableId); this.sDataTable.style.margin = "0px"; /* Otherwise looks bad */ if (this.cssSkin !== "") { this.sDataTable.className += " " + this.cssSkin; } if (this.sDataTable.getElementsByTagName("COLGROUP").length > 0) { this.sDataTable.removeChild(this.sDataTable.getElementsByTagName("COLGROUP")[0]); /* Making our own */ } this.sParent = this.sDataTable.parentNode; this.sParentHeight = this.sParent.offsetHeight; this.sParentWidth = this.sParent.offsetWidth; /////* Attach the required classNames */ this.sBase.className = "sBase"; this.sFHeader.className = "sFHeader"; this.sHeader.className = "sHeader"; this.sHeaderInner.className = "sHeaderInner"; this.sFData.className = "sFData"; this.sFDataInner.className = "sFDataInner"; this.sData.className = "sData"; /////* Clone parts of the data table for the new header table */ var alpha, beta, touched, clean, cleanRow, i, j, k, m, n, p; this.sHeaderTable = this.sDataTable.cloneNode(false); if (this.sDataTable.tHead) { alpha = this.sDataTable.tHead; this.sHeaderTable.appendChild(alpha.cloneNode(false)); beta = this.sHeaderTable.tHead; } else { alpha = this.sDataTable.tBodies[0]; this.sHeaderTable.appendChild(alpha.cloneNode(false)); beta = this.sHeaderTable.tBodies[0]; } alpha = alpha.rows; for (i=0; i 0) { this.sFHeaderTable = this.sHeaderTable.cloneNode(true); this.sFHeader.appendChild(this.sFHeaderTable); this.sFDataTable = this.sDataTable.cloneNode(true); this.sFDataInner.appendChild(this.sFDataTable); } /////* Set up the colGroup */ alpha = this.sDataTable.tBodies[0].rows; for (i=0, j=alpha.length; i 1 || rowSpan > 1 has been found */ } cleanRow = (clean === true) ? i : 0; /* Use this row index to calculate the column widths */ for (i=0, j=alpha[cleanRow].cells.length; i 0) { this.sFDataTable.insertBefore(this.sColGroup.cloneNode(true), this.sFDataTable.firstChild); this.sFHeaderTable.insertBefore(this.sColGroup.cloneNode(true), this.sFHeaderTable.firstChild); } /////* Style the tables individually if applicable */ if (this.cssSkin !== "") { this.sDataTable.className += " " + this.cssSkin + "-Main"; this.sHeaderTable.className += " " + this.cssSkin + "-Headers"; if (this.fixedCols > 0) { this.sFDataTable.className += " " + this.cssSkin + "-Fixed"; this.sFHeaderTable.className += " " + this.cssSkin + "-FixedHeaders"; } } /////* Throw everything into sBase */ if (this.fixedCols > 0) { this.sBase.appendChild(this.sFHeader); } this.sHeader.appendChild(this.sHeaderInner); this.sBase.appendChild(this.sHeader); if (this.fixedCols > 0) { this.sFData.appendChild(this.sFDataInner); this.sBase.appendChild(this.sFData); } this.sBase.appendChild(this.sData); this.sParent.insertBefore(this.sBase, this.sDataTable); this.sData.appendChild(this.sDataTable); /////* Align the tables */ var
相关内容
- asp.net实现DropDownList,TreeView,ListBox的无限极分类目录树_实用技巧_
- asp.net DataTable相关操作集锦(筛选,取前N条数据,去重复行,获取指定列数据等)_实用技巧_
- asp.net提取多层嵌套json数据的方法_实用技巧_
- Json.net 常用使用小结(推荐)_实用技巧_
- asp.net实现递归方法取出菜单并显示在DropDownList中(分栏形式)_实用技巧_
- ASP.NET生成二维码的方法总结_实用技巧_
- 实例解析Java中的synchronized关键字与线程安全问题_实用技巧_
- ASP.NET MVC+EF在服务端分页使用jqGrid以及jquery Datatables的注意事项_实用技巧_
- 厚积薄发,拥抱.NET 2016_实用技巧_
- asp.net实现固定GridView标题栏的方法(冻结列功能)_实用技巧_
点击排行
本栏推荐
