我认为你应该定义取消格式化程序(unformat http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter#unformatting)与格式化程序一起。例如,
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中)就像你可以使用的一样标准格式化程序 http://www.trirand.com/jqgridwiki/doku.php?id=wiki:predefined_formatter#predefined_format_types "integer"
, "date"
和别的。