easyUI中datagrid 将 text 设为不可编辑,该怎么处理
1、
var vareditor=$('#datagridId').datagrid('getEditor', { index:rowIndex, field:'fieldName' );
vareditor.target.prop('readonly', true);
2、扩展datagrid字段的editor
$.extend($.fn.datagrid.defaults.editors, {
textReadonly: {
init: function (container, options) {
var input = $('<input type="text" readonly="readonly" class="datagrid-editable-input">').appendTo(container);
return input;
},
getValue: function (target) {
return $(target).val();
},
setValue: function (target, value) {
$(target).val(value);
},
resize: function (target, width) {
var input = $(target);
if ($.boxModel == true) {
input.width(width - (input.outerWidth() - input.width()));
} else {
input.width(width);
}
}
}
});
然后字段的editor:'textReadonly'