I’ve create a listgrid for use in a Tabset (included via a external JS file).
I’m after creating a simple test application, which totals up the number of buildings and total number of bedrooms.
I searched the docs for a total column function but couldn’t find one could anyone point me in the right direction. At the moment the following will put a total in the right hand column if you edit a cell, click a different row, click back to the edited row and click a different row again.
var lastRecord = false;
countryData = [{property:"Semi",bedrooms1:"5",bedrooms2:"4",total:"9"},
{property:"Flat",bedrooms1:"3",bedrooms2:"5",total:"8"},
{property:"House",bedrooms1:"4",bedrooms2:"7",total:"11"},
{property:"Shed",bedrooms1:"1",bedrooms2:"0",total:"1"},
{property:"Total",bedrooms1:"13",bedrooms2:"16",total:"29"}];
VLayout.create({ID:"grid1",width:"100%", height:"100%",members: [
ListGrid.create({
ID: "countryList",
width:500, height:224, alternateRecordStyles:true,
showAllRecords:true,
data: countryData,
fields:[{name: "property", title: "Property", type:"text", canEdit: true},
{name: "bedrooms1", title: "Bedrooms 1", type:"integer", canEdit: true},
{name: "bedrooms2", title: "Bedrooms 2", type:"integer", canEdit: true},
{name: "total", title: "Total", type:"integer", canEdit: true}],
cellClick: function (record, rowNum, colNum) {
if (lastRecord) {
var newtotal = (lastRecord.bedrooms1*1)+(lastRecord.bedrooms2*1);
if (newtotal != lastRecord.total) {
lastRecord.total = newtotal;
grid1.markForRedraw();
}
}
lastRecord = record;
},
cellContextClick: "this.sayCellEvent('Context-clicked', record, colNum); return false;"
, autoFetchData: true
, canEdit: true
, editEvent: "click"
, editByCell: true
})]})
I have looked at cubegrid but it seems far to complex, to be honest I couldn’t get my head round it. Does it require the SC server package as well?
When it comes to submitting the listGrid to the server, how do I go about doing this? Ideally I would like the full grid to be editable and have a save button below - which would save all the changes at once.
I’ve managed to get the dynamic forms to save the data to the server but can’t get my head round how to do this for the listgrid.
Thanks for reading.