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?  

11 replies

null
    • Producer, Manager
    • Jan_Inge_Iversen
    • 1 yr ago
    • Reported - view

    Why no answer here?

    • Fred
    • 1 yr 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.

      • Producer, Manager
      • Jan_Inge_Iversen
      • 1 yr ago
      • Reported - view

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

    • Ninox developper
    • Jacques_TUR
    • 1 yr ago
    • Reported - view

    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.

      • Producer, Manager
      • Jan_Inge_Iversen
      • 1 yr ago
      • Reported - view

      Jacques TUR 
      Didn't get any of this to work...

      • Ninox developper
      • Jacques_TUR
      • 1 yr ago
      • Reported - view

      Jan Inge Iversen Do you have NativeJS installed?

      • Producer, Manager
      • Jan_Inge_Iversen
      • 1 yr ago
      • Reported - view

      Jacques TUR 
      Aha, I need an application to use those codes?
      No, I dont have NativeJS.

      • Ninox developper
      • Jacques_TUR
      • 1 yr ago
      • Reported - view

      Jan Inge Iversen Is juste one free extension for Ninox.

      See here about NativeJS : https://forum.ninox.com/t/g9h7l3a/ninext-native-javascript

      NativeJS is part of Ninext project : https://forum.ninox.com/t/p8h78zv/ninext-project

      • Producer, Manager
      • Jan_Inge_Iversen
      • 1 yr ago
      • Reported - view

      Jacques TUR 
      Where do I find it, and how do I install it?

      • Ninox developper
      • Jacques_TUR
      • 1 yr ago
      • Reported - view

      Jan Inge Iversen You need to install the Ninext project. It is explained here : https://forum.ninox.com/t/p8h78zv/ninext-project

      In the NativeJS post, there is an app attached with an example of how to install and use : https://forum.ninox.com/t/g9h7l3a/ninext-native-javascript

      • Producer, Manager
      • Jan_Inge_Iversen
      • 1 yr ago
      • Reported - view

      Jacques TUR 
      Thanks a lot, will do! 👍🙂

Content aside

  • 2 Likes
  • 1 yr agoLast active
  • 11Replies
  • 378Views
  • 3 Following