Results 1 to 4 of 4

Thread: Error in built application if form.standardSubmit=true

  1. #1
    Sencha User
    Join Date
    Jan 2014
    Posts
    22

    Default Error in built application if form.standardSubmit=true

    Hello,

    I need a way to download grid content as csv file. for that, I used a form and submitted it with standardSubmit=true and a url that points to a php file containing the necessary code to download the grid content.

    Everything goes fine when I start the application from Architect 3 (.0 and .1). But When I build the application and try to download the CSV file, I get un error.

    To demonstrate my problem, I created the simplest application in the world (after Hello world): a window+a form+ a button:

    application:
    Code:
    Ext.Loader.setConfig({
    
    });
    
    
    Ext.application({
        controllers: [
            'MyController'
        ],
        name: 't',
    
        launch: function() {
            Ext.create('t.view.MyWin', {renderTo: Ext.getBody()});
        }
    
    });
    Window:
    Code:
    Ext.define('t.view.MyWin', {
        extend: 'Ext.window.Window',
        alias: 'widget.mywin',
    
        requires: [
            't.view.MyWinViewModel',
            'Ext.form.Panel',
            'Ext.button.Button'
        ],
    
        viewModel: {
            type: 'mywin'
        },
        autoShow: true,
        height: 88,
        width: 353,
        layout: 'absolute',
        title: 'My Window',
    
        items: [
            {
                xtype: 'form',
                hidden: true,
                itemId: 'csvform',
                title: 'My Form',
                standardSubmit: true,
                url: 'php/downloadcsv.php'
            },
            {
                xtype: 'button',
                x: 140,
                y: 10,
                itemId: 'csvbtn',
                text: 'Download CSV'
            }
        ]
    
    });
    Controller:
    Code:
    Ext.define('t.controller.MyController', {
        extend: 'Ext.app.Controller',
    
        init: function(application) {
            this.control({
                "mywin button#csvbtn":{
                    click:this.onButtonClick
                }
            });
        },
    
        onButtonClick: function(btn, e, opts) {
            btn.up("window").down("form#csvform").getForm().submit({
                params:{
                    countryid:3,
                    country:'AFG'
                }
            });
        }
    
    });
    PHP file:
    PHP Code:
    require("db/db.php");

    function 
    array_to_csv_download($array$filename "export.csv"$delimiter=",") {
        
    header('Content-Type: application/csv');
        
    header('Content-type: application/force-download');
        
    header('Content-Disposition: attachement; filename="'.$filename.'"');

        
        
    $f fopen('php://output''w');

        foreach (
    $array as $line) {
            
    fputcsv($f$line$delimiter);
        }

    $countryid=$_REQUEST['countryid'];
    $country=$_REQUEST['country'];

        
    $sql="SELECT * FROM country WHERE countryid=$countryid";

    $result = array();
    $result[]=array('Col1','Col2','Col3');

    if (
    $rows $db->query($sql)) {
        while (
    $row $rows->fetch_array(MYSQLI_NUM)) 
            
    $result[]=$row;
    }
    array_to_csv_download($result,"$country.csv");
    $db->close(); 
    Application before build:
    dev.jpg

    Built application after clicking "Download CSV" button:
    build.jpg

    If I put myform.standardSubmit=false, I don't get this error in built application any more, but also I can't download CSV file any more.

    Could any one help PLEASE.

    Thank you in advance

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,255

    Default

    Which framework version are you using? In the built copy it's throwing an error, what does the stack trace look like there?
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3

    Default

    First you have to create the CSV from the following script
    toCSV(<document_id_of_kendo_grid>, [array of field names to export without template]);

    You have to download the CSV means use the following script. It is an example of CSV download
    <script src="swfobject.js"></script>
    <script src="downloadify.min.js"></script>


    <div id="gridId">Your Kendo Grid</div>
    <div id="downloadButton">Your download button</div>


    <script type="text/javascript">
    Downloadify.create('downloadButton', {
    filename: "filename.csv",
    data: function () {
    return "\uFEFF" + toCSV('gridId');
    },
    onComplete: function () { },
    onCancel: function () { },
    onError: function () { },
    transparent: false,
    swf: "downloadify.swf",
    downloadImage: "download.png",
    width: 100,
    height: 30,
    transparent: true,
    append: false
    });
    </script>

  4. #4
    Sencha User
    Join Date
    Jan 2014
    Posts
    22

    Default

    Framework: Ext JS 5.0.x

    Trace: I don't know if you mean this.

    GET http://localhost/tp/.js?_dc=1410879969080 404 (Not Found) (index):20d.fetch (index):20s.fetch (index):27s.loadSync (index):30s.load (index):30k.loadEntries (index):24d.processRequest (index):17d.loadSync (index):17d.load (index):17Ext.apply.loadScripts app.js?_dc=1410879966622:1Ext.apply.load app.js?_dc=1410879966622:1Ext.apply.require app.js?_dc=1410879966622:1Ext.apply.syncRequire app.js?_dc=1410879966622:1(anonymous function) app.js?_dc=1410879966622:1Ext.ClassManager.Ext.apply.create app.js?_dc=1410879966622:1Ext.ClassManager.Ext.apply.instantiateByAlias app.js?_dc=1410879966622:1Ext.cmd.derive.doAction app.js?_dc=1410879966622:1Ext.cmd.derive.submit app.js?_dc=1410879966622:1Ext.cmd.derive.onButtonClick app.js?_dc=1410879966622:1fire app.js?_dc=1410879966622:1Ext.cmd.derive.dispatch app.js?_dc=1410879966622:1Ext.Base.s.addMembers.callParent app.js?_dc=1410879966622:1Ext.cmd.derive.dispatch app.js?_dc=1410879966622:1f.doFireEvent app.js?_dc=1410879966622:1fireEventArgs app.js?_dc=1410879966622:1fireEvent app.js?_dc=1410879966622:1Ext.cmd.derive.fireHandler app.js?_dc=1410879966622:1Ext.cmd.derive.onClick app.js?_dc=1410879966622:1Ext.cmd.derive.doFire app.js?_dc=1410879966622:1Ext.cmd.derive.fire app.js?_dc=1410879966622:1Ext.cmd.derive.doDispatchEvent app.js?_dc=1410879966622:1Ext.cmd.derive.dispatch app.js?_dc=1410879966622:1Ext.cmd.derive.dispatch app.js?_dc=1410879966622:1Ext.cmd.derive.doPublish app.js?_dc=1410879966622:1Ext.cmd.derive.publish app.js?_dc=1410879966622:1Ext.cmd.derive.onRecognized app.js?_dc=1410879966622:1Ext.cmd.derive.fire app.js?_dc=1410879966622:1Ext.cmd.derive.onTouchEnd app.js?_dc=1410879966622:1Ext.cmd.derive.invokeRecognizers app.js?_dc=1410879966622:1Ext.cmd.derive.onTouchEnd app.js?_dc=1410879966622:1(anonymous function) app.js?_dc=1410879966622:1Ext.Function.v app.js?_dc=1410879966622:1

    Uncaught TypeError: object is not a function VM110:3(anonymous function) VM110:3Ext.ClassManager.Ext.apply.create app.js?_dc=1410879966622:1Ext.ClassManager.Ext.apply.instantiateByAlias app.js?_dc=1410879966622:1Ext.cmd.derive.doAction app.js?_dc=1410879966622:1Ext.cmd.derive.submit app.js?_dc=1410879966622:1Ext.cmd.derive.onButtonClick app.js?_dc=1410879966622:1fire app.js?_dc=1410879966622:1Ext.cmd.derive.dispatch app.js?_dc=1410879966622:1Ext.Base.s.addMembers.callParent app.js?_dc=1410879966622:1Ext.cmd.derive.dispatch app.js?_dc=1410879966622:1f.doFireEvent app.js?_dc=1410879966622:1fireEventArgs app.js?_dc=1410879966622:1fireEvent app.js?_dc=1410879966622:1Ext.cmd.derive.fireHandler app.js?_dc=1410879966622:1Ext.cmd.derive.onClick app.js?_dc=1410879966622:1Ext.cmd.derive.doFire app.js?_dc=1410879966622:1Ext.cmd.derive.fire app.js?_dc=1410879966622:1Ext.cmd.derive.doDispatchEvent app.js?_dc=1410879966622:1Ext.cmd.derive.dispatch app.js?_dc=1410879966622:1Ext.cmd.derive.dispatch app.js?_dc=1410879966622:1Ext.cmd.derive.doPublish app.js?_dc=1410879966622:1Ext.cmd.derive.publish app.js?_dc=1410879966622:1Ext.cmd.derive.onRecognized app.js?_dc=1410879966622:1Ext.cmd.derive.fire app.js?_dc=1410879966622:1Ext.cmd.derive.onTouchEnd app.js?_dc=1410879966622:1Ext.cmd.derive.invokeRecognizers app.js?_dc=1410879966622:1Ext.cmd.derive.onTouchEnd app.js?_dc=1410879966622:1(anonymous function) app.js?_dc=1410879966622:1Ext.Function.v

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •