change CSV delimiter

change CSV delimiter

boudgaboudga Posts: 11Questions: 0Answers: 0
edited February 2010 in TableTools
When using TableTools.js it automatically delimits generated CSVs with a comma as usual but I want to use a pipe. how can I change this in your JavaScript?

Replies

  • boudgaboudga Posts: 11Questions: 0Answers: 0
    In the TableTools.js I found this call fnGetDataTablesData(",") in the fnFeatureSaveCSV function and changed it to be fnGetDataTablesData("|") and my web page ignores the pipe and still outputs the comma even after clearing the cache.

    [code]
    function fnFeatureSaveCSV ()
    {
    var sBaseClass = "TableTools_button TableTools_csv";
    var nButton = document.createElement( 'div' );
    nButton.id = "ToolTables_CSV_"+_iId;
    nButton.style.height = _oSettings.iButtonHeight+'px';
    nButton.style.width = _oSettings.iButtonWidth+'px';
    nButton.className = sBaseClass;
    _nTools.appendChild( nButton );

    var clip = new ZeroClipboard.Client();
    clip.setHandCursor( true );
    clip.setAction( 'save' );
    clip.setFileName( fnGetTitle()+'.csv' );

    clip.addEventListener('mouseOver', function(client) {
    nButton.className = sBaseClass+'_hover';
    } );

    clip.addEventListener('mouseOut', function(client) {
    nButton.className = sBaseClass;
    } );

    clip.addEventListener('mouseDown', function(client) {
    clip.setText( fnGetDataTablesData("|") );
    } );

    fnGlue( clip, nButton, "ToolTables_CSV_"+_iId, "Save as CSV" );
    }
    [/code]
  • allanallan Posts: 54,909Questions: 1Answers: 8,606 Site admin
    Looks like you might be using an old version of TableTools - the line you want to change in the current version is:

    [code]
    fnFlashSetText( clip, fnGetDataTablesData(",", TableToolsInit.sCsvBoundary) );
    [/code]
    It would probably be worth upgrading.

    I didn't provide an option to change the separator, given the expansion of the CSV acronym :-). But changing that line should do the trick!

    Regards,
    Allan
This discussion has been closed.