我认为您应该将 unformatter ( unformat ) 与格式化程序一起定义。例如,
formatter: function (cellvalue) {
if (cellvalue == null) {
return "<span class='ui-icon ui-icon-pencil'></span>";
} else {
return cellvalue;
};
},
unformat: function (cellValue, options, elem) {
return $(elem).text();
}
我不确定如何unformat
在 struts2 网格插件中指定。
另一种方法是通过以下方式定义格式化程序
(function ($) {
"use strict";
/*jslint unparam: true */
$.extend($.fn.fmatter, {
yourFormatterName: function (cellValue, options) {
if (cellvalue == null) {
return "<span class='ui-icon ui-icon-pencil'></span>";
} else {
return cellvalue;
};
}
});
$.extend($.fn.fmatter.yourFormatterName, {
unformat: function (cellValue, options, elem) {
return $(elem).text();
}
});
}(jQuery));
它将允许您以与使用标准格式化程序等相同的方式使用formatter: "yourFormatterName"
(或可能formatter = "yourFormatterName"
在 struts2 中)。 "integer"
"date"