2

Using a button to export multiple records

I typically use the gear to export a selection of records to a CSV/Excel sheet.  What I would like to do is do this using a button.  How does one code for this?  

11replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Why no answer here?

    Like 1
    • Fred
    • Fred
    • 2 mths ago
    • Reported - view

    From the looks of it there is no way to export through a button. Maybe through javascript or through a json you can "export".

    One possiblility is the use of createTempFile, but I don't use the cloud version so I can't test it out.

    Like 1
    • Fred Its not a good version in case you are right, but I guess we will get an respectful answer any way?

      Like
  • Do you just want to open the export interface with a button?

    If so, you put this code on your button (need to use NativeJS)

    #{ ui.currentView.table.menuExportData() }#

    If you want to execute the export directly, you can do it with this code (only for the could version):

    var fileName := "myExport2.csv";
    var exportSettings := {
        sep: ",",
        qut: """",
        lf: "%0D%0A",
        numberFormat: "point",
        dateFormat: "locale",
        header: true,
        sepHeader: false,
        encoding: "utf8"
    }
    
    #{:text:callback
    window.util.renderCSV(window.database, window.ui.currentView.table, exportSettings)
        .then((textData) => {
            NinoxDocumentInteraction.openFileWithServer(fileName, 'text/csv', textData, !1, !0)
            callback(textData)
        })
    }#;

    exportSettings corresponds to the information requested from the user in the export interface.

    For App version, you can create text file with your data :

    var fileName := "myExport2.csv";
    var exportSettings := {
        sep: ",",
        qut: """",
        lf: "%0D%0A",
        numberFormat: "point",
        dateFormat: "locale",
        header: true,
        sepHeader: false,
        encoding: "utf8"
    }
    var data := #{:text:callback
        window.util.renderCSV(window.database, window.ui.currentView.table, exportSettings)
            .then((textData) => {
                callback(textData);
            })
    }#;
    createTextFile( this, data, fileName );

     The file is attached to current record.

    Like 1
Like2 Follow
  • 2 Likes
  • 2 mths agoLast active
  • 11Replies
  • 172Views
  • 3 Following