dojox/grid/enhanced/plugins/exporter/CSVWriter.js

  • Provides:

    • dojox.grid.enhanced.plugins.exporter.CSVWriter
  • Requires:

    • dojox.grid.enhanced.plugins.exporter._ExportWriter in common
  • dojox.grid.enhanced.plugins.exporter.CSVWriter

    • type
      Function
    • chains:
      • dojox.grid.enhanced.plugins.exporter._ExportWriter: (prototype)
      • dojox.grid.enhanced.plugins.exporter._ExportWriter: (call)
    • summary
      CSV default separator is ','.
      But we can also use our own.
    • parameters:
      • writerArgs: (typeof object)
        {separator:'...'}
    • source: [view]
        if(writerArgs){
         this._separator = writerArgs.separator ? writerArgs.separator : this._separator;
         this._newline = writerArgs.newline ? writerArgs.newline : this._newline;
        }
        this._headers = [];
        this._dataRows = [];
  • dojox.grid.enhanced.plugins.exporter.CSVWriter._separator

    • summary
  • dojox.grid.enhanced.plugins.exporter.CSVWriter._newline

    • summary
  • dojox.grid.enhanced.plugins.exporter.CSVWriter._formatCSVCell

    • type
      Function
    • parameters:
      • cellValue: (typeof string)
        The value in a cell.
    • source: [view]
        if(cellValue === null || cellValue === undefined){
         return '';
        }
        var result = String(cellValue).replace(/"/g, '""');
        if(result.indexOf(this._separator) >= 0 || result.search(/[" \t\r\n]/) >= 0){
         result = '"' + result + '"';
        }
        return result; //String
    • summary
      Format cell value to follow CSV standard.
      See: http://en.wikipedia.org/wiki/Comma-separated_values
    • tags:
    • return_summary
      The formatted content of a cell
    • returns
      String
  • dojox.grid.enhanced.plugins.exporter.CSVWriter.beforeContentRow

    • type
      Function
    • parameters:
      • arg_obj: (typeof object)
    • source: [view]
        var row = [],
         func = this._formatCSVCell;
        dojo.forEach(arg_obj.grid.layout.cells, function(cell){
         //We are not interested in indirect selectors and row indexes.
         if(!cell.hidden && dojo.indexOf(arg_obj.spCols,cell.index) < 0){
          //We only need data here, not html
          row.push(func(this._getExportDataForCell(arg_obj.rowIndex, arg_obj.row, cell, arg_obj.grid)));
         }
        }, this);
        this._dataRows.push(row);
        //We do not need to go into the row.
        return false; //Boolean
    • summary
      Overrided from _ExportWriter
    • returns
      Boolean
  • dojox.grid.enhanced.plugins.exporter.CSVWriter.handleCell

    • type
      Function
    • parameters:
      • arg_obj: (typeof object)
    • source: [view]
        var cell = arg_obj.cell;
        if(arg_obj.isHeader && !cell.hidden && dojo.indexOf(arg_obj.spCols,cell.index) < 0){
         this._headers.push(cell.name || cell.field);
        }
    • summary
      Overrided from _ExportWriter
  • dojox.grid.enhanced.plugins.exporter.CSVWriter.toString

    • type
      Function
    • source: [view]
        var result = this._headers.join(this._separator);
        for(var i = this._dataRows.length - 1; i >= 0; --i){
         this._dataRows[i] = this._dataRows[i].join(this._separator);
        }
        return result + this._newline + this._dataRows.join(this._newline); //String
    • summary
      Overrided from _ExportWriter
    • returns
      String
  • dojox.grid.enhanced.plugins.exporter.CSVWriter._headers

    • summary
  • dojox.grid.enhanced.plugins.exporter.CSVWriter._dataRows

    • summary
  • dojox.grid.enhanced.plugins.exporter

    • type
      Object
    • summary
  • dojox.grid.enhanced.plugins

    • type
      Object
    • summary
  • dojox.grid.enhanced

    • type
      Object
    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary