rtalmeida Posted July 29, 2017 Share Posted July 29, 2017 I need to consider in UniDBGrid1ColumnSummary only the selected rows in an unidbgrid that is with the property dgMultiSelect = True and dgCheckSelect = True, how can I do? Link to comment Share on other sites More sharing options...
Sherzod Posted July 30, 2017 Share Posted July 30, 2017 Hi, At the moment you can use this approach I think, for example: 1. UniDBGrid1 -> OnColumnSummary: procedure TMainForm.UniDBGrid1ColumnSummary(Column: TUniDBGridColumn; GroupFieldValue: Variant); begin if SameText(Column.FieldName, 'quantity') then begin //not needed end; end; 2. UniDBGrid1 -> OnColumnSummaryResult: procedure TMainForm.UniDBGrid1ColumnSummaryResult(Column: TUniDBGridColumn; GroupFieldValue: Variant; Attribs: TUniCellAttribs; var Result: string); var I, J : Integer; F : Real; begin if SameText(Column.FieldName, 'quantity') then begin // needed only for change Attribs Attribs.Font.Style:=[fsBold]; Attribs.Font.Color:=clGreen; end; end; 3. UniDBGrid1 -> ClientEvents -> ExtEvents -> function reconfigure: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { // 2 - your Column Index (zero based) columns[2].summaryRenderer = function(value, summaryData, dataIndex, metaData) { if (value && typeof value == "object") { var v = 0, va = value["_sa" + dataIndex], sty = null; sender.getSelectionModel().getSelection().forEach(function(sel){v += parseInt(sel.data[dataIndex])}); if (va) { try { eval("var fobj=" + va + ";") } catch (err) { _log(err.message) } if (typeof fobj != "object") { var fobj = {} } sty = fobj2style(fobj, false, true) } if (sty) { metaData.tdAttr = sty } return (v) } return "" } } 4. UniDBGrid1 -> ClientEvents -> ExtEvents -> [Ext.selection.CheckboxModel [checkboxModel]] -> function checkboxModel.selectionchange: function checkboxModel.selectionchange(sender, selected, eOpts) { sender.view.refresh(); } 5. UniDBGrid1 -> OnAfterLoad: procedure TMainForm.UniDBGrid1AfterLoad(Sender: TUniDBGrid); begin Sender.JSInterface.JSCode('Ext.defer(function(){'#1'.getView().refresh()}, 100);'); end; 6. And of course dgMultiSelect = True and dgCheckSelect = True and ShowSummary = True Result: Best regards, 1 Link to comment Share on other sites More sharing options...
rtalmeida Posted July 30, 2017 Author Share Posted July 30, 2017 Perfect! thank you so much again. Link to comment Share on other sites More sharing options...
rtalmeida Posted July 30, 2017 Author Share Posted July 30, 2017 Just one detail, it works only for integers? I changed parseInt to parsefloat but it made no difference. Link to comment Share on other sites More sharing options...
Sherzod Posted July 30, 2017 Share Posted July 30, 2017 Just one detail, it works only for integers? I changed parseInt to parsefloat but it made no difference. parseFloat(sel.data[dataIndex]) return (v.toFixed(2)) function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns[2].summaryRenderer = function(value, summaryData, dataIndex, metaData) { if (value && typeof value == "object") { var v = 0, va = value["_sa" + dataIndex], sty = null; sender.getSelectionModel().getSelection().forEach(function(sel){v += parseFloat(sel.data[dataIndex])}); if (va) { try { eval("var fobj=" + va + ";") } catch (err) { _log(err.message) } if (typeof fobj != "object") { var fobj = {} } sty = fobj2style(fobj, false, true) } if (sty) { metaData.tdAttr = sty } return (v.toFixed(2)) } return "" } } Link to comment Share on other sites More sharing options...
rtalmeida Posted July 30, 2017 Author Share Posted July 30, 2017 Unfortunately did not work, always show .00 Link to comment Share on other sites More sharing options...
Sherzod Posted July 31, 2017 Share Posted July 31, 2017 Hi, Unfortunately did not work, always show .00 What is the data type of your Field ? Link to comment Share on other sites More sharing options...
rtalmeida Posted July 31, 2017 Author Share Posted July 31, 2017 FloatField Link to comment Share on other sites More sharing options...
Sherzod Posted July 31, 2017 Share Posted July 31, 2017 Try with currency field too Link to comment Share on other sites More sharing options...
rtalmeida Posted July 31, 2017 Author Share Posted July 31, 2017 Thank you, now it's okay. Link to comment Share on other sites More sharing options...
freedowsRoO Posted November 25, 2019 Share Posted November 25, 2019 Hey @Sherzod how are you? I need almost the same thing. I have a paged grid with totals and filters, i need to refresh my grid totals when the grid is filtered. Is it possible? Thanks in advance. Link to comment Share on other sites More sharing options...
Sherzod Posted November 25, 2019 Share Posted November 25, 2019 29 minutes ago, freedowsRoO said: Hey @Sherzod how are you? I need almost the same thing. I have a paged grid with totals and filters, i need to refresh my grid totals when the grid is filtered. Is it possible? Hello, I'm fine, thank you. And you? Can you make a simple test case to see the problem? Link to comment Share on other sites More sharing options...
freedowsRoO Posted November 25, 2019 Share Posted November 25, 2019 1 hour ago, Sherzod said: Hello, I'm fine, thank you. And you? Can you make a simple test case to see the problem? Sorry i tried to make the test case but i don't managed because i use a FIREDAC component to connect with The database. The problem is simple, i made a summary paged dbgrid following the demo and after that i add a collumn filter. My summary is ok but when i use the column filter i need to recalc the summary totals. Link to comment Share on other sites More sharing options...
freedowsRoO Posted November 25, 2019 Share Posted November 25, 2019 I manage to do what i want thanks... 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now