sort row data grabber from input div

sort row data grabber from input div

IslanderIslander Posts: 4Questions: 0Answers: 0
edited July 2012 in Plug-ins
http://jsfiddle.net/tPpdj/2/

guys help me with this im noob to javascript/jquery

my td can contain input or div or nothing just plain numbers



or

12.00

or

41

all three types in a single row

im trying to modify that above plugin to grab values from any type of input or divs (so i can sort it) but dosent work

and http://datatables.net/forums/discussion/5836/hidden-table-sort/p1 i have seen this example also of using span inside the td but my tables td's will be mostly always 500+ so dont want to waste bandwidth or make it slow

please help me thanks :)

Replies

  • IslanderIslander Posts: 4Questions: 0Answers: 0
    nevermind i fixed it myself , if you guys think there is any error or can be done abetter way please let me know how , thanks

    [code]
    /* Create an array with the values of all the input boxes in a column */
    $.fn.dataTableExt.afnSortData['dom-text-all'] = function ( oSettings, iColumn ) {

    var aData = [];

    $( 'td:eq('+iColumn+')', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {

    var thiscol = $(this).find("input:first");

    if (thiscol.length > 0) {

    aData.push(thiscol.val());

    } else {

    var divtext = $(this).find("div");

    if (divtext.length > 0) {

    aData.push(divtext.text());

    } else {

    aData.push($(this).text());

    }

    }

    } );

    return aData;

    }
    [/code]

    =]
This discussion has been closed.