Hi Guys,
I have a little problem in migrating some code from an old system to one using DHTMLX grid.
I have a grid like this
suppLedgerGrid.setHeader(‘Date, Ref, Item, Debit, Credit, Balance’);
which pulls data from two tables, an invoice table and a payment table. I use the following SQL UNION statement to prepare the data on the server side :
$LedgerSQL = "select invoiceid as ItemID, invoicedate as ItemDate, invoiceref as ItemRef, ‘Invoice’ as ItemType, invtotal as ItemDebit, 0 as ItemCredit, ‘’ as ItemBalance from invoices where suppid=$_GET[SuppID] ";
$LedgerSQL .= "union select paymentid as ItemID, paymentdate as ItemDate, paymentref as ItemRef, ‘Payment’ as ItemType, 0 as ItemDebit, paymentamt as ItemCredit, ‘’ as ItemBalance from payments where suppid=$_GET[SuppID] ";
$LedgerSQL .= “order by ItemDate asc”;
$resconn->render_sql($LedgerSQL,“ItemID”, “ItemDate,ItemRef,ItemType,ItemDebit,ItemCredit,ItemBalance”);
In my old system when rendering the HTML table to display the results I iterated through the SQL results and built up the last column manually by adding/deleting a counter based on the results from each table.
I’d like the last column in the grid ‘ItemBalance’ to be previous row’s ‘ItemBalance’+(-ItemDebit)+ItemCredit
Maybe this is just not possible? I can’t figure out how to do it using render_sql…