-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grouping Widget: Separate grouping and sorting #1286
Comments
Hi @cgarwood! Is the first column never sorted? If you set the If you use $(function(){
$("#groups").tablesorter({
theme : "blue",
sortForce: [[0, 0]],
widgets: [ "group", "filter", "zebra" ],
widgetOptions: {
group_forceColumn: [0]
}
});
}); |
@Mottie thanks for the quick reply! The second example using sortForce and group_forceColumn is closest to what I'm wanting to achieve, but I would like to be able to switch which column is used for grouping without editing the JS file (for example, with a Group By: dropdown above the table). Is that possible using that method? |
The |
I'm not completely opposed to adding a new feature, I'd need to get a better idea of how to implement it when I do. |
So it seems that I have to set sortForce and group_forceColumn to whatever I want the grouping to be, and then actually click on a table header to change the sort options once the page loads. This gives me the correct grouping. However, for some reason it doesn't give me the correct grouping on first load of the page, I have to actually click a table header to get it to fix the groups. From outside of the constructor how would I go about changing the sortForce and group_forceColumn values? |
Add a $(function(){
$("#groups").tablesorter({
theme : "blue",
sortForce: [[0, 0]],
sortList: [[0, 0]],
widgets: [ "group", "filter", "zebra" ],
widgetOptions: {
group_forceColumn: [0]
}
});
}); |
How can we avoid something such as this when using your method? The initial sort is not abiding by the group_forceColumn. When you click to sort after initialization, then it functions correctly. |
Hi @kczx3! I'm not sure what you are expecting. The grouping is applied to the second column... please remember that the |
Correct, but why are there two groups for "B"? If you sort on column A after the demo loads, then the two group B's become one. How can we make it do this on load? |
Ahh, I forgot that setting a So on initialization, also include the $(function(){
$("#groups").tablesorter({
theme : "blue",
sortForce: [[1, 0]],
sortList: [[1,0], [0, 0]],
widgets: [ "group", "filter", "zebra" ],
widgetOptions: {
group_forceColumn: [1]
}
});
}); |
I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue the discussion in this thread. |
It would be nice to have separate grouping and sorting.
For example if you have the table:
It would be nice to group the table by ColA (sorted alphabetically), but sort the table within the groups by ColB or ColC
The text was updated successfully, but these errors were encountered: