jQWidgets Forums
Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
August 15, 2014 at 6:02 pm in reply to: Computed Column that will sort and use the cellclass Computed Column that will sort and use the cellclass #58416
I currently have the cellclass figured out per row:
var dataAdapter = new $.jqx.dataAdapter(source, { downloadComplete: function (data, status, xhr) { }, loadComplete: function (data) { setTimeout(function () { $(this).trigger("reloadGrid"); // Call to fix client-side sorting }, 50); }, loadError: function (xhr, status, error) { } }); $("#jqxgrid-trade-p").jqxGrid( { width: '100%', rowsheight: 40, autoheight: true, theme: "metrodark", sortable: true, source: dataAdapter, showaggregates: true, columnsresize: false, showstatusbar: true, statusbarheight: 40, altrows: true, columns: [ { text: 'Symbol', dataField: 'symbol', width: '15%' }, { text: 'Quantity', dataField: 'qty', width: '15%' }, { text: 'Last Price', dataField: 'lastPrice', cellsformat: 'c2', width: '15%' }, { text: 'Net Profit', datafield: 'netProfit', keys: true, sortable: true, cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { var netProfit = parseFloat(rowdata.costBasis) - parseFloat(rowdata.marketValue); if (netProfit < 0) { return "<div style='height: 100%; background: red; padding: 10px;'>" + dataAdapter.formatNumber(netProfit, "c2") + "</div>"; } else return "<div style='height: 100%; background: green; padding: 10px;'>" + dataAdapter.formatNumber(netProfit, "c2") + "</div>"; }, sorttype: function (cellValue, rowdata) { var netProfit = parseFloat(rowdata.costBasis) - parseFloat(rowdata.marketValue); return netProfit; } }, { text: 'Cost Per Share', datafield: 'total', cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { var total = parseFloat(rowdata.costBasis) / parseFloat(rowdata.qty); return "<div style='margin: 10px;' class='jqx-right-align'>" + dataAdapter.formatNumber(total, "c2") + "</div>"; } }, { text: 'Target Price', datafield: 'yahooTargetPrice', cellsformat: 'c2', width: '15%'} ] });
August 15, 2014 at 5:48 pm in reply to: Computed Column that will sort and use the cellclass Computed Column that will sort and use the cellclass #58415That makes sense. Can you give me an example of the setcellvalue? Would i have to go through each row as it is computed and set the value that way by looping through the rows?
for (var i = 0; i < rows.length; i++) {
My goal is to have that computed column sorted on page load.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)