// 初始化列表
initGird: function () {
alert(JSON.stringify(gridtable_KL_data));
var data = gridtable_KL_data;
//array of columns.
var colModel = [
{
title: "部门", //title of column.
align: "center", //垂直居中
hvalign: "center",//水平居中 "top", "center" and "bottom".
width:120, //initial width of column
dataType: "integer", //data type of column
dataIndx: "CCATCNAME", //should match one of the keys in row data.
styleHead: { 'font-weight': 'bold' } //应用样式
},
{
title: "大类", //title of column.
align: "center", //垂直居中
menuInDisable: true,//不能隐藏
hvalign: "center",//水平居中 "top", "center" and "bottom".
width: 100, //initial width of column
dataType: "integer", //data type of column
dataIndx: "JMDMKTNAME", //should match one of the keys in row data.
styleHead: { 'font-weight': 'bold' } //应用样式
},
{
title: "负责人",
hdenid: true,
width: 100,
menuInDisable: true,//不能隐藏
dataType: "string",
hvalign: "center",
align: "center",
dataIndx: "F_MANAGER",
styleHead: { 'font-weight': 'bold' } //应用样式
},
{
title: "月累计客流(人次)", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
{
title: "本期",
width: 60,
dataType: "float",
align: "right",
dataIndx: "SMDKLL",
//格式化
//format: function (val) {
// return val;
//},
summary: {
type: "sum"
}
//format: "#####"
},
{
title: "同期",
width: 60,
dataType: "float",
align: "right",
dataIndx: "SMDKLL2",
summary: {
type: "sum"
}
},
{
title: "差异",
width: 60,
dataType: "float",
align: "right",
dataIndx: "KLCY",
format: function (val) {
if (val <= 0) {
return redblack + val + endblack;
} else {
return black + '+' + val + endblack;
}
},
summary: {
type: "sum"
}
}]
},
{title: "占店比", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
{
title: "本店",
width: 60,
dataType: "float",
align: "right",
dataIndx: "profits"
}
,
{
title: "标杆",
width: 60,
dataType: "float",
align: "right",
dataIndx: "profits"
}
]
},
{
title: "客单价(元)", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
{
title: "本期",
width: 60,
dataType: "float",
align: "right",
dataIndx: "KDJ",
summary: {
type: "avg"
}
//format: function (val) {
// return val.toFixed(2);
//}
},
{
title: "同期",
width: 60,
dataType: "float",
align: "right",
dataIndx: "KDJ2",
summary: {
type: "avg"
}
//format: function (val) {
// return val.toFixed(2);
//}
} ,
{
title: "差异",
width: 60,
dataType: "float",
align: "right",
dataIndx: "KDJCY",
format: function (val) {
if (val <= 0) {
return redblack + Tnumber(val * 10000) + endblack;
} else {
return black + '+' + Tnumber(val * 10000) + endblack;
}
},
summary: {
type: "avg"
}
},
{
title: "增幅",
hdenid: true,
width: 60,
//menuInDisable: true,//不能隐藏
dataType: "string",
hvalign: "center",
align: "right",
//dataIndx: "company",
//styleHead: { 'font-weight': 'bold' } //应用样式
}]
},
{
title: "月累计销售(万元)", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
{
title: "本期",
width: 60,
dataType: "float",
align: "right",
dataIndx: "AXSSR",
format: function (val) {
return Tnumber(val);
}
},
{
title: "同期",
width: 60,
dataType: "float",
align: "right",
dataIndx: "BXSSR",
format: function (val) {
return Tnumber(val);
}
},
{
title: "差异",
width: 60,
dataType: "float",
align: "right",
dataIndx: "LJXSCY",
format: function (val) {
if (val >= 0) {
return black + Tnumber(val) + endblack;
} else {
return redblack + Tnumber(val) + endblack;
}
}
},
{
title: "增幅",
hdenid: true,
width: 60,
//menuInDisable: true,//不能隐藏
dataType: "string",
hvalign: "center",
align: "right",
dataIndx: "LJXSZZL",
format: function (val) {
if (val >= 0) {
return black + Tnumber(val * 10000) + '%' + endblack;
} else {
return redblack + Tnumber(val * 10000) + '%' + endblack;
}
}
//dataIndx: "company",
// styleHead: { 'font-weight': 'bold' } //应用样式
}]
},
{
title: "占店比", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
{
title: "本店",
width: 60,
dataType: "float",
align: "right",
dataIndx: "XSZB"
},
{
title: "标杆",
hdenid: true,
width: 60,
//menuInDisable: true,//不能隐藏
dataType: "string",
hvalign: "center",
align: "right",
dataIndx: "BGXSZB",
// styleHead: { 'font-weight': 'bold' } //应用样式
}]
}
];
var groupModel = {
on: true,
//checkbox: true, checkboxHead: true, cascade: true,
titleInFirstCol: true,
fixCols: false, indent: 18,
pivot: false,
agg: {
'AXSSR': 'sum',
'BXSSR': 'sum',
'LJXSCY': 'sum',
// 'LJXSCY': 'sum',
},
groupCols: ['qtr'],
collapsed: [false, false, false, false],
summaryInTitleRow: 'all', //to display summary in the title row.
dataIndx: ['CCATCNAME'],
//showSummary: [true], //to display summary at end of every group.
title: [
"{0} ({1})"
]
};
//main object to be passed to pqGrid constructor.
var obj = {
toolbar: {
items: [{
type: 'button',
label: "Toggle grouping",
listener: function () {
this.Group().option({
on: !this.option('groupModel.on')
});
}
}]
},
//分组不显示数据前的标题
summaryTitle: {
avg: "",
count: '',
max: "",
min: "",
stdev: "",
stdevp: "",
sum: ""
},
flex: {one: true},
menuIcon: true,
menuUI: {
tabs: ['hideCols']
},
dataModel: { data: data },
colModel: colModel,
formulas: [
["KLCY", function (rd) {
return rd.SMDKLL - rd.SMDKLL2;
}],
["KDJCY", function (rd) {
return rd.KDJ - rd.KDJ2;
}],
["LJXSCY", function (rd) {
return rd.AXSSR - rd.BXSSR;
}]
],
//合计
summaryData: [
{ CCATCNAME: '合计', summaryRow: true, pq_fn: { SMDKLL: 'sum(D:D)/2', SMDKLL2: 'sum(E:E)/2', KLCY: 'sum(F:F)/2', AXSSR: 'sum(M:M)/2', BXSSR: 'sum(N:N)/2', LJXSCY: 'sum(M:M)/2-sum(N:N)/2', LJXSZZL: 'round((sum(M:M)/2-sum(N:N)/2)/sum(N:N)/2,4)*100'} }
],
freezeCols: 2,
groupModel: groupModel,
title: "客单客流"
};
//$("#gridtable_KL").pqGrid(obj);
alert(JSON.stringify(obj.groupModel));
gridtable_KL = pq.grid("#gridtable_KL", obj);
var groupModel = gridtable_KL.option("groupModel");
$("#gridtable_KL").pqGrid("refreshDataAndView");
},