var defaultFields = [
{ name: "Title", type: "text", width: "", title: "용어명", css: "text-left col-md-9 col-sm-9 col-xs-9" },
{ name: "RegisterId", type: "text", width: "", title: "등록자", css: "text-center col-md-1 col-sm-1 col-xs-1" },
{ name: "RegistDate", type: "date", width: "", title: "등록일시", css: "text-center col-md-1 col-sm-1 col-xs-1" },
{ name: "UseYn", type: "text", width: "", title: "사용유무", css: "text-center col-md-1 col-sm-1 col-xs-1" }
];
var DateField = function (config) {
jsGrid.Field.call(this, config);
};
DateField.prototype = new jsGrid.Field({
itemTemplate: function (value) {
return new Date(value.match(/\d+/)[0] * 1).format("yyyy-MM-dd");
}
});
jsGrid.fields.date = DateField;
$(function () {
var formCollection = $("#termForm").serialize();
$("#btnRegist").on("click", function () {
location.replace("/Term/TermRegist");
});
});
$("#jsGrid").jsGrid({
width: "100%",
height: "auto",
inserting: false,
editing: false,
sorting: true,
heading: true,
paging: true,
pageSize: 10,
pageButtonCount: 10,
pagerContainer: "#externalPager",
pagerFormat: "{first} {prev} {pages} {next} {last}",
pagePrevText: "<span class=\"lightblue\"><</span>",
pageNextText: ">",
pageFirstText: "<<",
pageLastText: ">>",
pageNavigatorNextText: "…",
pageNavigatorPrevText: "…",
controller: {
loadData: function (filter) {
return $.ajax({
type: "GET",
url: "/Term/TermListForJson",
data: filter,
dataType: "JSON"
})
}
},
fields: defaultFields,
onPageChanged: function (args) {
$("input[name=pageNo]").val(args.pageIndex);
},
rowClick: function (args) {
location.replace("/Term/TermView/" + args.item.TermNo);
}
});
Date.prototype.format = function (f) {
if (!this.valueOf()) return " ";
var weekName = ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"];
var d = this;
return f.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function ($1) {
switch ($1) {
case "yyyy": return d.getFullYear();
case "yy": return (d.getFullYear() % 1000).zf(2);
case "MM": return (d.getMonth() + 1).zf(2);
case "dd": return d.getDate().zf(2);
case "E": return weekName[d.getDay()];
case "HH": return d.getHours().zf(2);
case "hh": return ((h = d.getHours() % 12) ? h : 12).zf(2);
case "mm": return d.getMinutes().zf(2);
case "ss": return d.getSeconds().zf(2);
case "a/p": return d.getHours() < 12 ? "오전" : "오후";
default: return $1;
}
});
};
String.prototype.string = function (len) { var s = '', i = 0; while (i++ < len) { s += this; } return s; };
String.prototype.zf = function (len) { return "0".string(len - this.length) + this; };
Number.prototype.zf = function (len) { return this.toString().zf(len); };