Problematic sorting requirement
Problematic sorting requirement
syndesis
Posts: 12Questions: 0Answers: 0
Debug: ahujef
Live: http://live.datatables.net/opubud
First off, thanks for creating and maintaining this software. I've used it a lot and always found it very helpful.
This code reflects several problems I had to solve in order to meet my requirements. I don't think all the functionality here affects the problem I'm currently facing, but I found 90% solutions to a lot of these things in these forums and spent a fair amount of time on the last 10% so maybe the code here can save someone else some time. Features implemented: drag and drop between tables with differing numbers of columns (preserving custom row IDs and classes), expandable / collapsible duplicate rows using filters, reset table button that transfers all data (preserving custom row IDs and classes) to another table.
Description: I have two datatables which are connected as jqueryui sortables so I can drag and drop rows between them. In both tables, rows need to be sorted by priority. In the left table, "duplicate" rows (defined as having identical Description columns) need to be grouped into an expandable/collapsible set. Re-sorting does not need to be allowed.
Problem: Difficult sorting requirements. Duplicate rows (there may be multiple) may have different priorities from their "main" row. If I expand the main row, the duplicate(s) show up somewhere else in the table according to their priority. In the example, rows with description "BBB." When they have the same priority like "AAA" they show up how I want them. If I do aaSortingFixed on Description, the rows are always grouped properly but they won't show up in proper priority order (high to low). I'm trying to figure out the best way to resolve this so that duplicates always show up directly under their main row while still being able to display all rows based on the priority of the main rows.
Thanks!
Live: http://live.datatables.net/opubud
First off, thanks for creating and maintaining this software. I've used it a lot and always found it very helpful.
This code reflects several problems I had to solve in order to meet my requirements. I don't think all the functionality here affects the problem I'm currently facing, but I found 90% solutions to a lot of these things in these forums and spent a fair amount of time on the last 10% so maybe the code here can save someone else some time. Features implemented: drag and drop between tables with differing numbers of columns (preserving custom row IDs and classes), expandable / collapsible duplicate rows using filters, reset table button that transfers all data (preserving custom row IDs and classes) to another table.
Description: I have two datatables which are connected as jqueryui sortables so I can drag and drop rows between them. In both tables, rows need to be sorted by priority. In the left table, "duplicate" rows (defined as having identical Description columns) need to be grouped into an expandable/collapsible set. Re-sorting does not need to be allowed.
Problem: Difficult sorting requirements. Duplicate rows (there may be multiple) may have different priorities from their "main" row. If I expand the main row, the duplicate(s) show up somewhere else in the table according to their priority. In the example, rows with description "BBB." When they have the same priority like "AAA" they show up how I want them. If I do aaSortingFixed on Description, the rows are always grouped properly but they won't show up in proper priority order (high to low). I'm trying to figure out the best way to resolve this so that duplicates always show up directly under their main row while still being able to display all rows based on the priority of the main rows.
Thanks!
This discussion has been closed.
Replies
Either way, DataTables doesn't do anything while such child rows, and thus won't sort them. If sorting is required on child rows, then I'm afraid that is something that needs to be done externally.
Regards,
Allan
Is there any way you can show me the page? I'm struggling to visualise it a little I'm afraid.
Allan
Debug: ahujef
Live: http://live.datatables.net/opubud
So am I correct in saying that the issue is that if you click the top arrow (row 3) its child row appears below the row 6?
As you say that's because of the ordering. The ordering being applied is the priority first, then the grouping (description), hence why it is out of order.
To keep the grouping, you would need to have it sort but he group first - but that causes the priority order to explode. Is that fundamentally the issue (sorry, I'm being a bit slow on the uptake today!)?
I'v got to confess, I'm not sure how to handle this in DataTables. Let me think about it a little bit and get back to you!
Allan
[code]
oSettings.aoData[iIndex]._anHidden[aInvisible[i]] = nTds[aInvisible[i]];
[/code]
I also wrote a corresponding fnGetTr plugin based on fnGetTds
[code]
/* plugin to retrieve TR object including invisible columns */
$.fn.dataTableExt.oApi.fnGetTr = function ( oSettings, mTr ) {
var cols = oSettings.aoColumns.length;
var iRow = (typeof mTr == 'object') ?
oSettings.oApi._fnNodeToDataIndex(oSettings, mTr) : mTr;
var nTr = oSettings.aoData[iRow].nTr;
var hiddenCells = oSettings.aoData[iRow]._anHidden;
for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn
I've not thought of a cunning way to meet your sorting requirements yet, but I have been thinking about it. I think one way or another its going to require some new code in DataTables to do it, but I'm not yet sure what form that code should take! I am continuing to think about it (sorry I'm going a bit slow at the moment :-) ).
Allan