포맷터와 함께 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();
}
나는 당신이 struts2 그리드 플러그인에 unformat
을 지정할 수있는 방법을 모르겠어요.
또 하나의 방법은 다음과 같은 방식으로 포맷을 정의하는 것입니다 그것은 당신이 standard formatters"integer"
, "date"
등을 사용할 수 있습니다처럼 같은 방법으로 formatter: "yourFormatterName"
(또는 struts2에서 아마 formatter = "yourFormatterName"
)를 사용할 수 있도록합니다
(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));
.
감사합니다. 언급 한대로 스트럿은 언폼 도구 확장 기능. 그러나 나는'$ .fn.fmatter is undefined'를 얻는다. 그것을 고칠 방법을 알려주시겠습니까? –
@AlirezaFattahi : ** jqGrid 뒤에 코드 **를 포함해야합니다 ('jquery.jqgrid.min.js' 다음에). '$ .fn.fmatter'을 정의한 jqGrid 코드의 [the line] (https://github.com/free-jqgrid/jqGrid/blob/v4.7.0/js/jquery.fmatter.js#L50)을 보라. – Oleg
당신은 맞지만 jrGrid를 사용하여 struts 플러그인을 사용할 때 코드를 어디에 넣을 수 있는지 찾을 수 없습니다. 나는 새로운 질문에 그것을 시도하려고하는 전문가가 나를 도울 수있는 힘이 될 수 있습니다. 감사! –