dhtmlx使用翻译(八)dhtmlxgrid 保存数据操作 使用后记

1.1.160 enableMathSerialization (mode)
版本:专业版 需要dhtmlxgrid_math.js支持
参数:
mode:true/false
用途:设置运算公式序列化
参考实例:
mygrid.enableMathSerialization(true);

1.1.161 serialize
版本:专业版
参数:
用途:返回构建当前grid的xml数据字符串
参考实例:
var str=mygrid.serialize();

1.1.162 serializeToCSV (textmode)
版本:专业版 需要dhtmlxgrid_nxml.js支持
参数:
textmode:true/false
用途:返回构建当前grid的csv数据
参考实例:
var csv=mygrid.serializeToCSV();
//只有text内容被序列化,忽略html元素
var csv=mygrid.serializeToCSV(true);

1.1.163 setFieldNam (mask)
暂时没用到

1.1.164 setSerializableColumns (list)
版本:专业版
参数:
list:是否序列化当前列
用途:设置grid各列是否序列化
参考实例:
mygrid.setSerializableColumns("true,false,false,true,false,false,false");

1.1.165 setSerializationLevel (userData, selectedAttr, config, changedAttr, onlyChanged, asCDATA)
版本:专业版
参数:
userData:true/false  是否使用当前数据序列化
selectedAttr:true/false 在被选中的xml节点中包含selected属性标识被选中
如<row id="null" selected="1">
config:true/false  是否包含<head>节点,罗列各列配置信息
changedAttr:true/false 是否修改的单元格中,在<cell>节点中包含是否修改属性
onlyChanged:true/false 是否仅包含修改过的row节点
asCDATA:true/false 是否使用CDATA格式,避免无效字符
用途:设置grid序列化配置
参考实例:
mygrid.setSerializationLevel(true,true,false,true,false,true);


1.3 个人使用后记
使用发现bug修改记录:

1.在dhtmlxgrid.js中有这么一句:
var imUrl=label.replace(/.*/[([^>]+)/]/,"$1");

真确应该写为:var imUrl=label.replace(/.*/[([^>]+)/].*/,"$1");不然没法子替换]With Icon后的字符串。即image的路径就不对了。
2. 注意在2.5版本中 dhtmlxgrid.js 中503行处
var next=Math.max((this._drsclmW ? this._drsclmW[fcols[i]]: 0),ms); 这里没有增加对this._drsclmW[fcols[i]]是否可用校验。
应改为:
var next=Math.max((this._drsclmW ? (this._drsclmW[fcols[i]]? this._drsclmW[fcols[i]]:0) : 0),ms);


3.由于parse采用的是同步加载数据的模式,所以可以自行扩展支持当前grid加载完毕后相应处理函数,不过实际上parse也提供回调函数接口

4 虽然grid提供了丰富的列格式定义,但这里可以自行定义,主要是修改dhtmlxgridcell.js即可。给个参考,新增一个带下划线的格式edu,这样可以配合onRowSelect事件实现单元值下划线连接方式
在dhtmlxgridcell.js中新增如下:
function eXcell_edu(cell) {
 if (cell) {
  this.cell = cell;
  this.grid = this.cell.parentNode.grid;
 }
 this.getValue = function () {
  if ((this.cell.firstChild) && ((this.cell.atag) && (this.cell.firstChild.tagName == this.cell.atag))) {
   return this.cell.firstChild.value;
  }
  if (this.cell._clearCell) {
   return "";
  }
  return (_isIE ? this.cell.innerText : this.cell.textContent);
 };
 this.setValue = function (val) {
  if (!val || val.toString()._dhx_trim() == "") {
   val = " ";
   this.cell._clearCell = true;
  } else {
   this.cell._clearCell = false;
  }
  this.setLabel("<u style='cursor=hand'>" + val + "</u>");
 };
}
eXcell_edu.prototype = new eXcell_ed;

5 对于需要隐藏的数据列,也可以采用定义列宽为0的方式

getRowId(ind),如果数据没有指定id值,则返回 id = 当前行索引+1;

 

(注:本人文章均为原创,转载请注明出处!20100630写于深圳。)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值