Hi paramvir
The key point of what I want is how to look up the corresponding data in DB and display it on the screen if I choose one from the Year-Month List.
That is, it is how the dataModel portion from the source below is transferred to the year-month selected by call.
I'd really appreciate it if you could let me the solution.
{ // 13-2)
type: 'select',
label: '<b>Year-Month: ',options: [{ '2022-02': '2022-02', '2022-03': '2022-03', '2022-04': '2022-04', '2022-05': '2022-05' }],
listener: function (evt) {
// $(evt.target).val()
}
},
(Skip the middle)
dataModel: {
dataType: 'JSON',
location: 'remote',
recIndx: 'id',
url: "pp2_product_plan_save.php?mt_product=2022-05&cd_wc=W120",
getData: function (response){
debugger;
response.data.forEach(function (rd) {
// comment data
if (rd.pq_cellattr) rd.pq_cellattr = JSON.parse(rd.pq_cellattr);
if (rd.pq_cellstyle) rd.pq_cellstyle = JSON.parse(rd.pq_cellstyle);
if (rd.cd_kind < 4) { // stock data
Object.defineProperty(rd, 'total_this_month1', {
get (){
//return tot_this_month;
var rd = this, total = 0;
for(var i=1;i<=31;i++){
total += rd['qty' + i];
}
return total;
}
})
Object.defineProperty(rd, 'total_this_month2', {
get (){
//return tot_this_month;
var rd = this, total = 0;
for(var i=1;i<=31;i++){
total += rd['qty' + i];
}
return total;
}
})
}
else if(rd.cd_kind == 4){ // stock data
Object.defineProperty(rd, 'qty1', {
enumerable: true, get() {
var rd = this, ri = rd.pq_ri, pdata = grid.pageData(),
pre_month_stock = rd['total_pre_month'],
day = (pdata && pdata[ri - 4]) ? pdata[ri - 4].qty1 : 0,
night = (pdata && pdata[ri - 3]) ? pdata[ri - 3].qty1 : 0,
shipment = (pdata && pdata[ri - 2]) ? pdata[ri - 2].qty1 : 0,
etc = (pdata && pdata[ri - 1]) ? pdata[ri - 1].qty1 : 0;
return pre_month_stock + day + night - shipment - etc;
}
});
for(var i=2; i<=31; i++){
(function(qty, i){
Object.defineProperty(rd, qty, {
enumerable: true, get() {
var rd = this, ri = rd.pq_ri, pdata = grid.pageData(),
pre_day_stock = (pdata && pdata[ri]) ? pdata[ri]['qty'+(i-1)] : 0,
day = (pdata && pdata[ri - 4]) ? pdata[ri - 4][qty] : 0,
night = (pdata && pdata[ri - 3]) ? pdata[ri - 3][qty] : 0,
shipment = (pdata && pdata[ri - 2]) ? pdata[ri - 2][qty] : 0,
etc = (pdata && pdata[ri - 1]) ? pdata[ri - 1][qty] : 0;
return stock_this_month = pre_day_stock + day + night - shipment - etc;
}
});
})('qty'+i, i)
}
Object.defineProperty(rd, 'total_this_month1', {
get (){
var stock_this_month = rd['qty31'];
return stock_this_month;
}
})
Object.defineProperty(rd, 'total_this_month2', {
get (){
var stock_this_month = rd['qty31'];
return stock_this_month;
}
})
}
})
this.option('summaryData', calculateSummary(this));
return response;
}
},
(The following is omitted)