效果图如下:
说明:当点击Gridview列中的—符号时,该被选列被隐藏掉,自动显示在下边的下拉框中,当选中下拉框中的某列时,该列在
在Gridview中又显示出来
解决方案:
需要在程序中需要引入一个JS 源码如下:(ShowHideColumn.js)
// Hide each cell in a gridview column
function HideCol(gridView, colIndex, colName) {
var rows = document.getElementById(gridView).rows;
for(i = 0; i < rows.length; i++)
if(rows[i].id != gridView + "_pager")
rows[i].cells[colIndex].style.display = "none";
// Add the name and index of the hidden column to the dropdown list
var hiddenCols = document.getElementById(gridView + "_showCols");
hiddenCols.options[hiddenCols.length] = new Option(colName, colIndex);
SetupHiddenCols(gridView);
}
// Show each cell in a gridview column
function ShowCol(gridView, colIndex) {
var rows = document.getElementById(gridView).rows;
for(i = 0; i < rows.length; i++)
if(rows[i].id != gridView + "_pager")
rows[i].cells[colIndex].style.display = "";
// Remove the name and index of the hidden column from the dropdown list
var hiddenCols = document.getElementById(gridView + "_showCols&#