Keep track of certain resort rent payments recorded through the following json file data, loading as url in jqGrid 5:
{"rows":[{"id":"tzct01","trsctNo":"001","oprtDte":"22/01/24","amntToPay":440,"pymntTerm":"21/01/24-31/01/24","dueDate":"24/01/24","notes":"period full advnce payment",
"rcpts":[{"rcptNo":"0280","rcptDte":"18/01/24","rcptAmnt":440,"descrpt":"plata în avans prda: 21/01/24-31/01/24"}]
},
{"id":"tzct02","trsctNo":"002","oprtDte":"06/02/24","amntToPay":1160,"pymntTerm":"01/02/24-29/02/24","dueDate":"20/02/24","notes":"plata integrl in avans perioada rfrita",
"rcpts":[{"rcptNo":"0284","rcptDte":"04/02/24","rcptAmnt":1160,"descrpt":"plata în avans prda: 01/02/24-29/02/24"}]
},
{"id":"tzct03","trsctNo": "003","oprtDte": "24/03/24","amntToPay":800,"pymntTerm":"01/03/24-20/03/24","dueDate":"10/03/24","notes":"plata partial priada rfrita",
"rcpts":[{"rcptNo":"0291","rcptDte":"05/03/24","rcptAmnt":100,"descrpt":"plata prtl. în avans prda: 01/03/24-20/03/24"}]
},
{"id":"tzct04","trsctNo":"004","oprtDte":"14/04/24","amntToPay":440,"pymntTerm":"21/03/24-31/03/24","dueDate":"01/04/24","notes":"fara plati ...",
"rcpts":"No detailed data for tzct04"},
{"id":"tzct05","trsctNo":"005","oprtDte":"22/04/24","amntToPay":1200,"pymntTerm":"01/04/24-30/04/24","dueDate":"11/04/24","notes":"fara plati ...",
"rcpts":"No detailed data for tzct05"},
{"id":"tzct06","trsctNo":"006","oprtDte":"05/05/24","amntToPay":1240,"pymntTerm":"01/05/24-31/05/24","dueDate":"14/05/24","notes":"plata partial prioade anterioare",
"rcpts":[{"rcptNo":"0311","rcptDte":"02/05/24","rcptAmnt":500,"descrpt":"Detailed explanation for tzct06"}]
},
{"id":"tzct07","trsctNo":"007","oprtDte":"14/06/24","amntToPay":1000,"pymntTerm":"01/06/24-30/06/24","dueDate":"25/06/24","notes":"plata partial prioade anterioare",
"rcpts":[{"rcptNo":"0323","rcptDte":"10/06/24","rcptAmnt":1200,"descrpt":"Detailed explanation for tzct07_1"},
{"rcptNo":"0324","rcptDte":"25/06/24","rcptAmnt":1000,"descrpt":"Detailed explanation for tzct07_2"}]
},
...
{"id":"tzct10","trsctNo":"010","oprtDte":"29/09/24","amntToPay":1000,"pymntTerm":"01/09/24-30/09/24","dueDate":"27/09/24","notes":"plata partial prioade anterioare",
"rcpts":[{"rcptNo":"0349","rcptDte":"26/09/24","rcptAmnt":1000,"descrpt":"plata chirie pt sptmbr.'24"}]
},
{"id":"tzct11","trsctNo":"011","oprtDte":"26/10/24","amntToPay":1000,"pymntTerm":"01/10/24-31/10/24","dueDate":"27/10/24","notes":"plata partial prioade anterioare",
"rcpts":[{"rcptNo":"0352","rcptDte":"25/10/24","rcptAmnt":1000,"descrpt":"plata chirie pt oct.'24"}]
},
{"id":"tzct12","trsctNo":"012","oprtDte":"29/11/24","amntToPay":1000,"pymntTerm":"01/11/24-30/11/24","dueDate":"28/11/24","notes":"plata partial prioade anterioare",
"rcpts":[{"rcptNo":"0356","rcptDte":"25/11/24","rcptAmnt":1000,"descrpt":"plata chirie pt nov.'24"}]
}]
}
As one would notice there is some sort of principal record line starting with that id:tzct01 which has some corresponding “rcpts” subrecord detail
And through the following jq/jqGrid code
$(function()
{
$("#jqGrd").empty()
$('<div id="divDoi" style="width:78%; overflow:auto;"><table id="list2" cellspacing="0" cellpadding="0" width="60%"></table>' +
'<div id="gridpgr2"></div></div>').appendTo('#jqGrd')
$.ajax({url:'json/pmnts_ops.json',dataType:'json',
success:function(data)
{
var rows = data.rows,
rowHdrs=['IB (Init.Blnc)','Oprt Dte','Amnt Pay','Stay Period','Due Date','Totl Amnt To Pay','Cashed In','Pymnt Date','Ending Sum (FB)','Notes'], numColsPerPag=3,crrntPag=1,totPges=Math.ceil(rows.length/numColsPerPag),lastCB=0,pagDtaCache={}
function loadPage(page)
{
if(pagDtaCache[page])
{
updateGrid(pagDtaCache[page])
return
}
var start = (page-1)*numColsPerPag, end = Math.min(start+numColsPerPag,rows.length),
pagedData = rowHdrs.map(function(header)
{
return {header:header}
})
for(i=start;i<end;i++)
{
var row = rows[i]
rowHdrs.forEach(function(header,idx)
{
var cellData = ''
switch(header)
{
case 'IB (Init.Blnc)':
cellData = i === start ? lastCB : pagedData[8]['rcrd'+(i-1)] || 0
break
case 'Oprt Dte':
cellData = row.oprtDte || ''
break
case 'Amnt Pay':
cellData = row.amntToPay || 0
break
case 'Stay Period':
cellData = row.pymntTerm || ''
break
case 'Due Date':
cellData = row.dueDate || ''
break
case 'Totl Amnt To Pay':
var prevRst = pagedData[0]['rcrd'+i] || 0
cellData = (row.amntToPay || 0) + prevRst
break
case 'Cashed In':
var chtnteArray = Array.isArray(row.rcpts) ? row.rcpts:[]
cellData = chtnteArray.reduce(function(sum,item)
{
return sum + (item.rcptAmnt || 0)
}, 0)
break
case 'Pymnt Date':
cellData = row.rcpts && row.rcpts.length > 0 ? row.rcpts[row.rcpts.length-1].rcptDte : ''
break
case 'Ending Sum (FB)':
var TotlAmntPay = pagedData[5]['rcrd'+i] || 0, pyd = pagedData[6]['rcrd'+i] || 0
cellData = TotlAmntPay - pyd
lastCB = cellData
break
case 'Notes':
cellData = row.notes || ''
break
}
pagedData[idx]['rcrd'+i] = cellData // trnspse rcrds hdrs; do not touch this!
})
}
pagDtaCache[page] = {data:pagedData,colModel:generateColModel(start,end,page)}
updateGrid(pagDtaCache[page]) // grid update with the new data
}
function generateColModel(start,end,page)
{
var colModel = [{name:'header',label:'CrrtNo',width:150,align:'left',sortable:false}]
for(i=start;i<end;i++) // for each page, dynamically update label
colModel.push({name:'rcrd'+i,label:i+1,width:150,align:'left',sortable:false})
return colModel
}
function updateGrid(pageData)
{
if($("#list2").jqGrid('getGridParam','data'))
$("#list2").jqGrid('clearGridData').jqGrid('setGridParam',{data:pageData.data,
colModel:pageData.colModel,datatype:'local'}).trigger('reloadGrid')
else // initialize the grid if not already created
$("#list2").jqGrid({datatype:'local',data:pageData.data,colModel:pageData.colModel,
rowNum:rowHdrs.length,pager:'#gridpgr2',viewrecords:true,height:'auto',caption:'Rsrt's Rents Paymnts Display', altRows:true,loadonce:true,autowidth:false,shrinkToFit:false})
}
function updatePagination()
{
$('#gridpgr2').html('')
if(totPges>1)
{
$('<span style="margin-left:6cm;font-size:15px;">Page:</span>').appendTo('#gridpgr2')
for(i=1;i<=totPges;i++)
{
var link = $('<a href="#" style="left-margin:1px;padding:2 5px;font-size:16px;">'+i+ '</a>')
if(i==crrntPag)
{
link.css("font-weight",'bold') // no effect whatsoever, and dont't get it why ..
link.css("text-decoration",'underline')
}
link.appendTo('#gridpgr2').on('click',(function(i)
{
return function(e)
{
crrntPag = i
loadPage(crrntPag)
updatePagination()
}
})(i))
}
}
}
loadPage(crrntPag)
updatePagination()
},
error:function() {
console.error("Failed to load json data")
}
})
})
one could correctly somehow displays transposed rows with columns data along with computed data also. Reason for this transposition (switch lines with columns and vice-versa) is that all this
displaying will be made over the mobile devices.
The actual display with the current jq code is showcased through the Fig1.1 to Fig1.3
In the following, one’ll briefly describe all the specs and requirments for this showcase presenting what is already done it and also a couple of requirments which need to be done
As one could see from this code snippet (and also from the Fig. 1.1 and Fig1.2 etc), json data is succesfully manually and programmaticaly displayed, with transposed rows data as columns and columns as rows..
Only need to display 3 columns at a time (and, of course through this paginations .. one will reach other pages as well)
Next one’ll precisely depict how columns will gonna look like
(Notice some of them are physically present through the json data file while others are calculated fields)
I’ll mention along which ones bounds physical data and which one are computed fields
Here one goes over each column’s row:
1.1 First Column (header cells)
1.’CrrntNo’- sequential numbering json data records (keeps track of every and each record);
2.’IB'(Initial Balance)
– Opening Amount for the whole cash in operations; at first (the very first record) this
amount is 0; but starting with the second one, this value reads the previous record closing balance/ending; very important to keep this in mind
3.’Operation/Transact Date’
- The Date at which this very transaction was made;
4.’Amnt Pay’
- Amount to Pay strictly for the given time period;
5.’Stay Period’
- That’s the Recourse Period for which one will gonna have to pay;
6.’Due Date’
- Due Date by which the Rent (Amount to Pay at least) should be paid;
7.’Totl Amnt To Pay’
– Here’s the Total Amount to Pay which is the ‘IB’ + ‘Amnt Pay’
8.’Cashed In’
– That’s the Total Amount payed within current month; which is sum of all ‘rcptAmnt’
associated with this particular record
9.’Pymnt Date’
– Payment Date – the Date at which the payment (‘Cashed In’) has been made
10.’Ending Sum (FB)’
– That’s the Closing Balance (CB) or the Remaining Payment Amount is ‘Totl Amnt To Pay’ minus ‘Cashed In’; this CB will be reported then as next record’s opening balance as already mentioned when talked about Initial Balance at the first point; very important to get this
11.’Notes’
– short transact description
Next I’ll precisely describe some of the values (both physical as well as computed) which appear up in the jqGrid
1.2 Second Column (Data Cells)
-
1 – only this one is header (header cell)
-
- 0 – computed field (0 required if this is the very first row, else become ‘Ending Sum (FB)’ of the prev. line)
-
- “22/01/24” – physical data cell
-
-
- “21/01/24-31/01/24” – physical data cell
-
- “24/01/24” – physical data cell
-
- 440 – computed field (‘IB’ + ‘Amnt Pay’)
-
- 440 – computed data cell (SUM (‘rcptAmnt’) from the corresponding ‘rcpts’ subgrid data)
-
- “18/01/24” – physical data cell (last ‘rcptDte’ field from “rcpts” subgrid data)
-
- 0 – computed data cell (‘Totl Amnt To Pay’ – ‘Cashed In’)
-
- ‘period full advnc pymnt’ – physical data cell
1.3 Third Column (Data Cells)
-
- 2 header sequence value (only this one is header)
-
- 0 – computed field (Ending Sum (FB)’ of the prev. line)
-
- “06/02/24” – physical data cell
-
- 1160 – physical data cell
-
- “01/02/24-29/02/24” – physical data cell
-
- “20/02/24” – physical data cell
-
- 1160 – computed field (‘IB’ + ‘Amnt Pay’)
-
- 1160 – computed data cell (SUM (‘rcptAmnt’) from the corresponding subgrid data)
-
- “04/02/24” – physical data cell (last ‘rcptDte’ field from “rcpts” subgrid data)
-
- 0 – computed data cell (‘Totl Amnt To Pay’ – ‘Cashed In’)
-
- ‘period full advnc pymnt’ – physical data cell
and so on and so forth..
All the computations are practically the same as they were when everything was horizontally displayed.
Basically how it is right now all the computations reads quite well on all pages but still there are some requirments which are presented bellow
Requirments:
-
Very important, one should programatically have that very first row
‘NrCrt 1 2 3’ as main Header; which over the first line is exactly the same,
but for the other pages that top header, horizontally will have to read
'NrCrt 4 5 6 '(second page)
'NrCrt 7 8 9 '(third page)
and so on
Extremely important .. so I repeat one will just vertically (over the columns) numbering the records by vertically placing the record numbers as columns names (also spanning across pages)
by sticking the following cell headers
'NrCrt 1 2 3' (1st page)
'NrCrt 4 5 6' (2nd page)
'NrCrt 7 8 9' (3rd page)
'NrCrt 10 ' (4th page)
so there will only be roughly 12 rows on all pages
Unfortunatelly right now
‘NrCrt 1 2 3’ appears over all four pages !
3. Only three data lines on the page (which becomes columns)
4. Every vertical column will have a receipts subgrid data ALSO as columns..
This should be displayed as some sort of 1 to n relationship
As one could notice from fig.2.1, there should be added a plus sign between square brackets on a ‘Cashed In’ line for every single column indicating that this record has a subsequent one or more receipts sub-records associated (at least 1) with it. And also when hovering mouse over the +/- sign the mouse simbol will turn into that little palm symbol
And if one will click over that plus sign (+) this line (column actually) will expand, showing all the corresponding receipts data detail. And when expanded, that (+) plus sign turns over the minus sign (-) which when clicked will collapse that entire vertical receipts subgrid data, reverting back on the initial display.
All the corresponding receipts are regarded as a sub-record(s) for that principal transaction record as depicted through the Fig2.2
Please you guys also check the pics where everything appears exactly how it is right now and also how things should stand based on all the stuff mentioned
Thank you all, and please assist me through this matter