easyui datagrid动态修改editor时动态绑定combobox的数据

原文
http://blog.csdn.net/donggua3694857/article/details/51433882
/点击单元格触发的事件
function onClickCell(index, field) {
if (endEditing() && fag) {
KaTeX parse error: Expected 'EOF', got '#' at position 3: ('#̲subDg').datagri…("#taskLevels").val(); //数据源 如: 11,22,33,44,55,
if(field==“taskLevel” && taskLevelsData){//下拉编辑列时触发 taskLevel 为列名
var editors = $(’#subDg’).datagrid(‘getEditors’, index);//取当前的编辑器
var row = $(’#subDg’).datagrid(‘getRows’)[index];
var smEditor = editors[0];
$(smEditor.target).combobox({
onLoadSuccess: function () { //远程加载时触发
},
onShowPanel: function(){ //下拉展开时动态修改options
var data = [];
   $.each(taskLevelsData.split(","),function(i,e){
var obj={};
obj.id=e;
obj.text=e;
data.push(obj);
  })
                 $(smEditor.target).combobox(“loadData”, data);
//设置值
KaTeX parse error: Expected 'EOF', got '}' at position 94: … }̲ …(’#subDg’).datagrid(‘validateRow’, editIndex)) {
$(’#subDg’).datagrid(‘endEdit’, editIndex);
editIndex = undefined;
return true;
} else {
return false;
}
}

$ . e x t e n d ( .extend( .extend(.fn.datagrid.methods, {
editCell: function (jq, param) {
return jq.each(function () {
var opts = $(this).datagrid(‘options’);
var fields = ( t h i s ) . d a t a g r i d ( ′ g e t C o l u m n F i e l d s ′ , t r u e ) . c o n c a t ( (this).datagrid('getColumnFields', true).concat( (this).datagrid(getColumnFields,true).concat((this).datagrid(‘getColumnFields’));
for (var i = 0; i < fields.length; i++) {
var col = $(this).datagrid(‘getColumnOption’, fields[i]);
col.editor1 = col.editor;
if (fields[i] != param.field) {
col.editor = null;
}
}
$(this).datagrid(‘beginEdit’, param.index);
for (var i = 0; i < fields.length; i++) {
var col = $(this).datagrid(‘getColumnOption’, fields[i]);
col.editor = col.editor1;
}
});
}
});

你可能感兴趣的:(笔记)