我建议您使用custom formatter 或像the answer 或this one 中描述的那样注册您的自定义格式化程序,然后调用原始自定义格式化程序inside of:
(function ($) {
"use strict";
$.extend($.fn.fmatter, {
yourFormatterName: function (cellValue, options,
rowObject, action) {
// call formatter: "checkbox"
return $.fn.fmatter.call(this, "checkbox",
cellValue, options, rowObject, action);
}
});
$.extend($.fn.fmatter.yourFormatterName, {
unformat: function (cellValue, options, elem) {
var cbv = (options.colModel.editoptions != null &&
typeof options.colModel.editoptions.value === "string") ?
options.colModel.editoptions.value.split(":") :
["Yes","No"];
ret = $("input", elem).is(":checked") ? cbv[0] : cbv[1];
}
});
}(jQuery));
在调用原始格式化程序之前,您可以更改options.colModel 的任何属性:
yourFormatterName: function (cellValue, options, rowObject, action) {
var myValue = true, // or false value DYNAMICALLY
newOptions = $.extend(true, {
colModel: { formatoptions: { disabled: myValue } }
},
options);
return $.fn.fmatter.call(this, "checkbox", cellValue, newOptions, rowObject,
action);
}
在哪里