Author Topic: Sorting of grouped data using non-group by column confusing  (Read 350 times)

jim@solver.com

  • Pro OEM
  • Newbie
  • *
  • Posts: 12
    • View Profile
I am currently using version 8.3.0.

I have a grid with one grouped column and two date columns. When I click the header for date1 all of the data is sorted including the grouped column. When I click the header of date2 the data is only sorted within each group.

I checked your Grouped Rows demo https://www.paramquery.com/pro/demos/export and found the same behavior. When the "Freight" column header is clicked the "ShipCountry" column row order changes but when "Shipping Via", "Shipped Date" or "Shipping City" headers are clicked the "ShipCountry" retains its alphabetical sorting and the sorted column data is sorted with its group.

I checked the demo code and didn't find special sort configurations to cause this behavior. What is causing this difference in sort behavior?

I would like to configure my grid to behave like the "Freight" column unless the group by column has been sorted by the user.

Thanks for your help!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5637
    • View Profile
Re: Sorting of grouped data using non-group by column confusing
« Reply #1 on: July 12, 2022, 11:12:06 am »
Jim

Difference between Freight and other columns is that Freight is a summary column and it's quite useful and makes sense to see a summary column sorted as a whole after applying grouping.

Other columns can be sorted as a whole either by removing grouping or by using Ctrl key along with click on header cell.
« Last Edit: July 12, 2022, 11:16:03 am by paramvir »

jim@solver.com

  • Pro OEM
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Sorting of grouped data using non-group by column confusing
« Reply #2 on: July 12, 2022, 08:58:55 pm »
That is an interesting feature.

My date2 column is a summary column of nested JSON data so it gets its data from a a row template getter. Could that be affecting the behavior?

When I use the Ctrl-click on the header it does sort the groups also but when I Ctrl-click until the sort is removed the group sort does not return to its initial state.

Thanks for your help,

Jim

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5637
    • View Profile
Re: Sorting of grouped data using non-group by column confusing
« Reply #3 on: July 13, 2022, 11:25:02 pm »
1) Nested json data works the same way. Kindly share a jsfiddle if you want me to check.

2) That has been fixed in upcoming version.

jim@solver.com

  • Pro OEM
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Sorting of grouped data using non-group by column confusing
« Reply #4 on: August 11, 2022, 05:53:57 am »
I waited for the 8.5.0 release before revisiting this issue. I am still having problems with sorting columns that display nested JSON even when there is a summary defined for the column. During my testing I also found that the nested JSON columns are not summarized properly.
  • When the colModel contains a groupModel with a group column the summaries are not calculated.
  • When the summaries are not calculated the column sorts as if there were no summary so the data is sorted within the group unless Ctrl-Click is used for sorting.
I created this JSFiddle so you can see what is happening: https://jsfiddle.net/jhschmidt/rLbcn4ws/2/
  • Try closing the company group. Observe that the Revenues and Profits summaries are Sum: $0.00
  • Try opening the company group and sort by Revenue. Observe that the Revenues only sort within the group as if there were no summary.
While testing with the JSFiddle I discovered that the issue is caused by the group column being defined in the colModel. If the groupModel does not contain a column and the column is added after initialization the summaries are calculated correctly and sorting works as expected.

I hope this helps with this issue.

Thanks,
Jim

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5637
    • View Profile
Re: Sorting of grouped data using non-group by column confusing
« Reply #5 on: August 12, 2022, 11:35:45 am »
Jim

Thanks for pointing out the issue and jsfiddle. I'm able to reproduce the issue and have been looking into it.

jim@solver.com

  • Pro OEM
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Sorting of grouped data using non-group by column confusing
« Reply #6 on: August 13, 2022, 01:08:03 am »
I did some debugging and found that the rowTemplate accessors are added to the row data in cRefresh.addRowIndx() which occurs after the row data is summarized by the call to self.groupData() in onDataReady on line 15996. The row data is extended in cRefresh.addRowIndx() by a call to pq.extendT() which on line 1189 tests for an undefined property. Unfortunately the property has already been assigned a value when the summary is created so the accessor to the nested JSON data is not assigned.

I hope this helps,
Jim

Code: [Select]
onDataReady: function() {
var self = this,
that = self.that,
GM = that.options.groupModel,
GMLen = GM.dataIndx.length;
if (GM.on) {
if (GMLen || GM.grandSummary) {
if (that._trigger("isSkipGroup") !== false) {
self.groupData();
self.buildCache()
}
that.iRefresh.addRowIndx();
self.refreshColumns();
if (GMLen) {
self.initcollapsed();
self.initmerge();
if (self.isCascade(GM)) {
self.cascadeInit()
}
}
} else {
self.refreshColumns()
}
self.setValCBox()
}
self.createHeader()
},

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5637
    • View Profile
Re: Sorting of grouped data using non-group by column confusing
« Reply #7 on: September 05, 2022, 09:10:44 pm »
This has been fixed in v8.6.0

jim@solver.com

  • Pro OEM
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Sorting of grouped data using non-group by column confusing
« Reply #8 on: September 07, 2022, 03:10:33 am »
I tested the 8.6.0 version and the summary data is now being calculated correctly and sorting is correct for nested JSON data. Thanks for the fix!