dont sort first row

dont sort first row

r3tryr3try Posts: 11Questions: 0Answers: 0
edited December 2012 in DataTables 1.9
Hi, i have a datatable where the first row is the insert-row (css-class=InsertRow)

I want to ignore that row when sorting the table so that the insert-row is always the first row.

edit:
following code seems to work despite the fact, that the first row moves either way...
when i debug the code the array gets constructed just like i want it to (insertrow is first entry) but the row is shown somewhere else either way.

[code]
jQuery.fn.dataTableExt.afnSortData['dom-text'] = function (oSettings, iColumn) {
var aData = [];
jQuery('td:eq(' + iColumn + ') input[type=text]:first', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
var col = jQuery(this).closest('tr');
if (col.hasClass('InsertRow')) {
aData.unshift("-1");//insert at front
} else {
aData.push(this.value);//append to back
}
});
return aData;
}[/code]


What am i doing wrong here?

Best regards,
r3try

Replies

  • r3tryr3try Posts: 11Questions: 0Answers: 0
    Does really noone have a clue on how to solve this?
    Im thankful for every clue on this issue....

    best regards,
    r3try
  • r3tryr3try Posts: 11Questions: 0Answers: 0
    guess that's a no...
  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    Workaround - Place your insert row in the table header itself. On click add / insert a row. I assume sort is applied only to the [code] tbody tr td [/code]. This way your insert row is not sorted
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It should be perfectly possible to us a sorting plug-in to do what you are looking for, so I guess there is something going 'hiccup' in your plug-in. Please link to a test case: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
  • r3tryr3try Posts: 11Questions: 0Answers: 0
    edited December 2012
    ok, i did a testcase:

    http://live.datatables.net/erupuf/2/edit

    what can i do to fix the first row? (class of tr element is InsertRow)
  • r3tryr3try Posts: 11Questions: 0Answers: 0
    can someone please give me a hint on how to proceed, i dont have any clue what i could try anymore...
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'd suggest a different approach. Rather than rewriting the sorting, use fnDrawCallback and just insert your extra row on every draw.

    Allan
  • r3tryr3try Posts: 11Questions: 0Answers: 0
    But i am using a listview as generator for my markup and for the provided insert-functionality, so i cant really do that with my approach. Or do you see a way?
  • r3tryr3try Posts: 11Questions: 0Answers: 0
    push - is there any expert who knows how to rewrite the sorting-plugin to archive my goal?
  • r3tryr3try Posts: 11Questions: 0Answers: 0
    last desperation-push....
This discussion has been closed.