multiple sType for the column

multiple sType for the column

blaazetechblaazetech Posts: 5Questions: 0Answers: 0
edited October 2013 in General
hi allan,

am having data in mixed mode like currency wrapped in html link
[code]$2,834.98[/code]

and am unable to figure out the sorting issue as i cannot specify multiple sType for this.

any help is deeply appreciated.

thnx
blaaze

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Sounds like you want this plug-in: http://datatables.net/plug-ins/sorting#numbers_html

    Also, DataTables 1.10 will be able to sort this kind of data by numbers automatically :-).

    Allan
  • blaazetechblaazetech Posts: 5Questions: 0Answers: 0
    hi allan,

    i hope you didn't got my point, the data inside the html link is some currency which needs some custom handling, i cannot use currency and html stypes at once. i have edited the in my prior post, check again.

    thnx
    blaaze
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'm not sure you got mine :-). You need a sorting plug-in which will remove the HTML and the currency formatting if you want it to be a number. The html number sorting plug-in I linked to won't do exactly that, but a trivial modification to remove the currency formatting will do it.

    Or you could try the 1.10 dev code ( https://github.com/DataTables/DataTables/tree/1_10_wip ) which has this feature built in.

    Allan
  • blaazetechblaazetech Posts: 5Questions: 0Answers: 0
    The new issue arised, your 1.10 wip code worked for me but the following code is not working.
    [code]$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
    {
    if ( sNewSource !== undefined && sNewSource !== null ) {
    oSettings.sAjaxSource = sNewSource;
    }

    // Server-side processing should just call fnDraw
    if ( oSettings.oFeatures.bServerSide ) {
    this.fnDraw();
    return;
    }

    this.oApi._fnProcessingDisplay( oSettings, true );
    var that = this;
    var iStart = oSettings._iDisplayStart;
    var aData = [];

    this.oApi._fnServerParams( oSettings, aData );

    oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aData, function(json) {
    /* Clear the old information from the table */
    that.oApi._fnClearTable( oSettings );

    /* Got the data - add it to the table */
    var aData = (oSettings.sAjaxDataProp !== "") ?
    that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;

    for ( var i=0 ; i
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    fnReloadAjax is redundant in 1.10. Use `$('#myTable').DataTable().ajax.reload();` instead.

    Allan
  • blaazetechblaazetech Posts: 5Questions: 0Answers: 0
    i cannot change the whole code now, as i wrote custom reloadajax calls many places, i guess rolling back to initial question i might need to have a custom stype for this, can you guide me on this what i need to use to rip html, currency symbols and commas and consider it as a currency to sort and find fastly.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Sure, just use a regular expression to strip out non-numeric data, replacing it with empty, then replace the comma with a dot and parse the result as a floating point number.

    Allan
  • blaazetechblaazetech Posts: 5Questions: 0Answers: 0
    hi

    an example code will help me a lot, as am a kind of intermediate user.
    your code helps me a lot.

    thnx
This discussion has been closed.