rtalmeida Posted July 29, 2017 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? Quote
Sherzod Posted July 30, 2017 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 Quote
rtalmeida Posted July 30, 2017 Author Posted July 30, 2017 Just one detail, it works only for integers? I changed parseInt to parsefloat but it made no difference. Quote
Sherzod Posted July 30, 2017 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 "" } } Quote
rtalmeida Posted July 30, 2017 Author Posted July 30, 2017 Unfortunately did not work, always show .00 Quote
Sherzod Posted July 31, 2017 Posted July 31, 2017 Hi, Unfortunately did not work, always show .00 What is the data type of your Field ? Quote
freedowsRoO Posted November 25, 2019 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. Quote
Sherzod Posted November 25, 2019 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? Quote
freedowsRoO Posted November 25, 2019 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. Quote
freedowsRoO Posted November 25, 2019 Posted November 25, 2019 I manage to do what i want thanks... 1 Quote
diegojmap Posted October 2, 2024 Posted October 2, 2024 i could only get the selected total using our exemple code but i also need to show in another row all the total without selecting itens how can i do this? Quote
Sherzod Posted October 3, 2024 Posted October 3, 2024 13 hours ago, diegojmap said: i could only get the selected total using our exemple code but i also need to show in another row all the total without selecting itens how can i do this? Hello, If I understood you correctly, perhaps this solution will suit you? Quote
diegojmap Posted October 3, 2024 Posted October 3, 2024 kinda. Using your Screenshot i want your Total cost and at the same time i want to show the "selected total cost" but when i use the the function GetSelection() i cant show all the total cost at the same time So basically i cant combine both solutions at the same time As you can see on my screenshot i got 1 item selected and its working, but the total cost of both itens aren't showing even without selecting the first item Quote
Sherzod Posted October 3, 2024 Posted October 3, 2024 4 hours ago, Sherzod said: @diegojmap I changed the code to display both totals, I haven't provided the code yet. 1 Quote
diegojmap Posted October 4, 2024 Posted October 4, 2024 @Sherzod Hey could you help me? its the only thing im missing to finish my project Quote
Sherzod Posted October 4, 2024 Posted October 4, 2024 16 minutes ago, diegojmap said: Hey could you help me? One of the possible solutions at the moment, but keep in mind that we are changing the uniGUI method, and in future versions this solution may not work properly... Let's test this solution on this demo example: \FMSoft\Framework\uniGUI\Demos\Desktop\GridSummary function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { // columns[2] - third column columns[2].summaryRenderer = function(value, summaryData, dataIndex, metaData) { if (value && typeof value == "object") { var v = 0, sumv = value["_s" + dataIndex], 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 ("Total Units (selected): " + v + "<br>" + sumv) } return "" } } function selectionchange(sender, selected, eOpts) { sender.grid.getView().refresh(); } Quote
diegojmap Posted October 4, 2024 Posted October 4, 2024 Well, after some testing i got another problem. while i have just a few itens showing on screen it worked very well. But when i have to scroll down the page and i select an item all the itens just desapear. I would like to fix it. I uploaded a video to show what is happening VideoSummary.mp4 Quote
Sherzod Posted October 5, 2024 Posted October 5, 2024 21 hours ago, diegojmap said: Well, after some testing i got another problem. Sorry, I couldn't reproduce your issue. Quote
diegojmap Posted October 7, 2024 Posted October 7, 2024 I'm sending you the demo I created to debug the problem Im having in my project. Also a screenshot showing the minor change I did in your code. It was only the amount of itens i wanna show on screen. I hope it helps you to reproduce the problem. GridSummary.zip Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.