一个系统中有时候会为了方便用户操作,由用户决定显示列表中的哪些数据,示例如下:
下面我们看下用jQuery如何实现,有哪些注意点。
抽出来的公用的jQuery代码如下:
$(document).ready(function() {
//显示默认列
ErgodicCbl();
//单击确定按钮触发
$("input[belong='btnQuery']").click(function() {
ErgodicCbl();
return false;
})
$("input[belong='btnReset']").click(function() {
return true;
})
})
//遍历checkboxlist根据选中值控制列的显示
function ErgodicCbl() {
var indexCol = 0;
$("input[belong='cblCustomList']:checkbox").each(function() {
indexCol = FindIndex($(this).attr('text'));
if (true == $(this).attr("checked")) {
//选中则显示
showColumn(indexCol);
}
else {
//