dhtmlxgrid 自定义单元格 edit getValue setValue 事件
2012-06-04 23:59
253 查看
在国内,关于dhtmlxgrid的用法,介绍的不多,由于项目上用到,我自定义单元格的时候,重写edit事件的时候,遇到了好多的问题,如,我点击单元格的时候进于编辑状态的时候,单元格的值取不到,边为空,或光标离开的时候,单元格还是处于选中的状态,经过很久的调试,终于调好,在此,贴出代码,希望给遇到同样的朋友带去一点帮助。
//自定义单元格类型_方案上报类型
function eXcell_scheType(cell){
this.base = eXcell_ed;
this.base(cell)
var SCHEME_NAME="";
this.getValue=function(){
return cell.firstChild.value;
}
this.detach=function(){ //此事件也要写上不然网页会报错的(ie8);
//this.setValue(this.cell.firstChild.value);
return this.cell.firstChild.value;
}
this.edit=function(){
var edCell=(this.cell.innerHTML.toString()).indexOf("<");
if(edCell>0){
var cellV = cell.innerHTML.substring(0,edCell);
this.cell.innerHTML="<input type='text' id='cl'/>"; //save current value
this.cell.firstChild.value=cellV;
// this.cell.firstChild.innerHTML=cellV;
}else{
var flag_r=this.cell.innerHTML;
this.cell.innerHTML="<input type='text' id='cl'/>";
this.cell.firstChild.value=flag_r;
//this.cell.firstChild.innerHTML=SCHEME_NAME;
}
}
this.setValue = function(val){
//先查出方案的名称
var sqlStm="select s.OPERATE_SCHEME_NAME from MODEL_OPERATE_SCHEME s where s.SCHEME_ID='"+val+"'";
//alert(sqlStm);
DWREngine.setAsync(false);
db2Json.selectSimpleData(sqlStm,function(data){
SCHEME_NAME=eval(data);
//alert("yyyy "+SCHEME_NAME[][0]);
var sql="select SCHEME_TYPE from model_sendmanage_unit t where t.UNIT_ID='"+g_unitId+"' and t.USER_ID='"+USERID+"' and t.MODEL_ID='"+g_metaModelId+"' and t.SCHEME_ID='"+val+"'";
db2Json.selectSimpleData(sql,function(dat){
var flag=eval(dat);
var schemeFlag="";
for(var i=0;i<flag.length; i++){
for (j=0; j < flag[i].length; j++)
{
schemeFlag=flag[i][j];
if(schemeFlag=="1"){
SCHEME_NAME=SCHEME_NAME+"<span style='color: #f00;'>已经上传为高方案</span>";
}else if("2"==schemeFlag){
SCHEME_NAME=SCHEME_NAME+"<span style='color: #f00;'>已经上传为中方案</span>";
}else if("3"==schemeFlag){
SCHEME_NAME=SCHEME_NAME+"<span style='color: #f00;'>已经上传为低方案</span>";
}
}
}
cell.innerHTML=SCHEME_NAME;
});
});
DWREngine.setAsync(true);
}
}
eXcell_scheType.prototype = new eXcell_ed;
//自定义单元格类型_方案上报类型
function eXcell_scheType(cell){
this.base = eXcell_ed;
this.base(cell)
var SCHEME_NAME="";
this.getValue=function(){
return cell.firstChild.value;
}
this.detach=function(){ //此事件也要写上不然网页会报错的(ie8);
//this.setValue(this.cell.firstChild.value);
return this.cell.firstChild.value;
}
this.edit=function(){
var edCell=(this.cell.innerHTML.toString()).indexOf("<");
if(edCell>0){
var cellV = cell.innerHTML.substring(0,edCell);
this.cell.innerHTML="<input type='text' id='cl'/>"; //save current value
this.cell.firstChild.value=cellV;
// this.cell.firstChild.innerHTML=cellV;
}else{
var flag_r=this.cell.innerHTML;
this.cell.innerHTML="<input type='text' id='cl'/>";
this.cell.firstChild.value=flag_r;
//this.cell.firstChild.innerHTML=SCHEME_NAME;
}
}
this.setValue = function(val){
//先查出方案的名称
var sqlStm="select s.OPERATE_SCHEME_NAME from MODEL_OPERATE_SCHEME s where s.SCHEME_ID='"+val+"'";
//alert(sqlStm);
DWREngine.setAsync(false);
db2Json.selectSimpleData(sqlStm,function(data){
SCHEME_NAME=eval(data);
//alert("yyyy "+SCHEME_NAME[][0]);
var sql="select SCHEME_TYPE from model_sendmanage_unit t where t.UNIT_ID='"+g_unitId+"' and t.USER_ID='"+USERID+"' and t.MODEL_ID='"+g_metaModelId+"' and t.SCHEME_ID='"+val+"'";
db2Json.selectSimpleData(sql,function(dat){
var flag=eval(dat);
var schemeFlag="";
for(var i=0;i<flag.length; i++){
for (j=0; j < flag[i].length; j++)
{
schemeFlag=flag[i][j];
if(schemeFlag=="1"){
SCHEME_NAME=SCHEME_NAME+"<span style='color: #f00;'>已经上传为高方案</span>";
}else if("2"==schemeFlag){
SCHEME_NAME=SCHEME_NAME+"<span style='color: #f00;'>已经上传为中方案</span>";
}else if("3"==schemeFlag){
SCHEME_NAME=SCHEME_NAME+"<span style='color: #f00;'>已经上传为低方案</span>";
}
}
}
cell.innerHTML=SCHEME_NAME;
});
});
DWREngine.setAsync(true);
}
}
eXcell_scheType.prototype = new eXcell_ed;
相关文章推荐
- 第二讲实例变量可见度,set/get方法,自定义初始化(代码) 及description的使用
- UI BOL 练习 get value set attr
- C# 参考之上下文关键字get、set、value、partial、where和yield
- 过程:先Edit,然后SetFieldValue,接着Update,最后MoveNext
- C# 参考之上下文关键字get、set、value、partial、where和yield
- flex/in the datagrid,how to get the new value of cell in the datagrid after edit
- Python asyncio文档翻译---事件环规则:通用的消息循环EventLoop的get,set方法
- C# 参考之上下文关键字:get、set、value (ZT)
- 自定义Field Type的Control时,Field值得Get和Set是通过重载Value属性实现的
- Android EditText setOnClickListener事件 只有获取焦点才能响应 采用setOnTouchListener解决
- 关于PropertyInfo setvalue()和PropertyInfo getvalue()
- 自定义对象, 绑定get, set 方法
- 自定义对话框AlertDialog.getWindow().setContentView(view)是EditText无法输入
- C#中的属性(get、set、value)
- C#定义属性及其关键字get,set,value
- easyui datagrid editor onBeforeEdit事件下使用getEditor和getEditors失效
- 调用js报错:try { document.getElementById("").SetReturnValue(__flash__toXML(MY_FUNCTION(
- C#中的属性(get、set、value)
- Objective-C,ios,属性声明(property declarations), 自定义属性,自动生成 get 和 set 方法,getter 和 setter
- Memcached expire 设置错误引起的set(key,exp,value)为true而get(key)为null的问题