Hi Folks
I found a clue to my problem indirectly in the post “Trouble with ConvertToDataSet” posted by andres_achiary March 2009.
THe following code allowed me to get my calculated fields data in a GROUP BY query spanning multiple tables, and place it in a newly created form which gives me the grid with sort functionality etc. I now just need to add the form back to my existing forms tabpanel. The solution may not be best practice, but does the job. Saves creating calculated fields in database. Hope it’s of use to someone.
Here’s a simplified version of the code
//Start of working example using GROUP BY clause into grid on form
var maxReturnedRows = 20
// FixEventz.eveid is pk
var lcQuery = “SELECT fixeventz.eveid, max(fixeventz.evename) as evename, sum(cosledg.ldgqty2*1234.567) as balance” +
" FROM fixeventz INNER JOIN cosledg ON fixeventz.eveid = cosledg.ldgeveid " +
" GROUP BY eveid ";
var vDataSet = databaseManager.getDataSetByQuery(globals.active_database, lcQuery, null, maxReturnedRows);
var vResult = vDataSet.createDataSource(‘mydata2’,[JSColumn.INTEGER, JSColumn.TEXT, JSColumn.INTEGER]); // types are inferred from query result
history.removeForm(‘frm_test’)
solutionModel.removeForm(‘frm_test’)
var jsform = solutionModel.newForm(‘frm_test’, vResult, null, true, 300, 300);
jsform.newField(“eveid”,SM_DISPLAYTYPE.TEXT_FIELD,100,100,100,20)
jsform.newField(“evename”,SM_DISPLAYTYPE.TEXT_FIELD,200,200,100,20)
jsform.newField(“balance”,SM_DISPLAYTYPE.TEXT_FIELD,200,200,100,20)
jsform.view = JSForm.LOCKED_TABLE_VIEW
forms.frm_test.controller.show()
//End of test code