问题描述
我们项目通过YUI进行的查询操作。function init() {contentColumnHeaders =[{key:"select",text:"选择",width:"20em",type:"link"}, {key:"policyNo",text:"保单号",width:"30em",sortable:true,type:"link"}, {key:"contractNo",text:"合同号",width:"30em",sortable:true}, {key:"insuredName",text:"被保险人",width:"30em",sortable:true}, {key:"startDate",text:"保险起期",width:"30em",sortable:true,type:"date"}, {key:"operatorCode",text:"操作员",width:"40em",sortable:true}, {key:"inputTime",text:"输入时间",width:"40em",sortable:true,type:"date"} ]; //设置链接数据格式信息(主要用于处理与主键相关和操作相关的信息) YAHOO.widget.Column.formatLink = function(elCell, oRecord, oColumn, oData) { //获取主键信息var oProposalNo = oRecord.proposalNo;if(oColumn.key=="createTime" || oColumn.key=="updateTime"){ var date = new Date(oData.time); elCell.innerHTML = date.toLocaleString(); } else if(oColumn.key=="select") {elCell.innerHTML="<input type='radio' name='ichkbox' id='ichkbox' />"; } else if(oColumn.key=="policyNo") {elCell.innerHTML="<label>"+ oData +"</label><input type ='hidden' name='ipolicyNo' id= 'ipolicyNo' value='"+oData +"' />"; } else { elCell.innerHTML = oData; }}; //设置日期转换格式YAHOO.widget.Column.formatDate = function (elCell, oRecord, oColumn, oData) { //取得单元格的内容 var value = oData;//如果字段不为空,则进行格式处理 if (value != "") { var date = new Date(oData.time); if (oColumn.key == "startDate") { value = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); } else { value = date.toLocaleString(); } } elCell.innerHTML = value; };}上面代码就是点击查询,显示在页面上的列,但是我想要某些列做为隐藏域,现在不知道怎么处理。 问题补充: {key:"policyNo",text:"保单号",width:"30em",sortable:true,type:"link"}不知道这里有没有什么参数,可以设置成此列为隐藏。
解决方案
YUI datetable设置隐藏列 属性 visible:false {key:"select",text:"选择",width:"20em",type:"link",visible:false}, 详见api:http://yuilibrary.com/yui/docs/api/classes/DataTable.html#method_hide