How to post Spreadsheet data to php script

2 posts, 0 answers
  1. Reinier
    Reinier avatar
    2 posts
    Member since:
    Oct 2016

    Posted 04 Nov Link to this post

    Hi,

    I have build a nice spreadsheet with the UI for PHP.

    The PHP script retrieves data from a MySQL database and populates the spreadsheet.

    Now, I try to POST the spreadsheet data to another PHP script that will update the MySQL database tables.

    Unfortunately I do not manage to post the spreadsheet data to the PHP script. It keeps posting an empty array.

    If I use the demo version "Spreadsheet / Server Import/Export" - HTML5/JavaScript source (http://demos.telerik.com/kendo-ui/spreadsheet/server-side-import-export) and just set the "<form action='' to my PHP script, it works as a charm. But it does not post the data from the spreadsheet I created with PHP.

    Does anybody knows what to do to get this working?

     

    I have attached the php script.

  2. Reinier
    Reinier avatar
    2 posts
    Member since:
    Oct 2016

    Posted 06 Nov in reply to Reinier Link to this post

    I have changed this code in the widget.php:

    1) added this property:

    public additional_jquery_code

    2) and at the bottom of the script:

    if ($executeOnDomReady) {
        // added Reinier 20161006 to add code to activate Data save to php script
        $script[] = $this->additional_jquery_code;

        //end of added line

        $script[] = '});';

     }

     

    Then, in the php script that builds and renders the html page:

     

    <?php 

    require_once 'lib/Kendo/Autoload.php';



     

    // Create a new instance of Spreadsheet and specify its id

    $spreadsheet = new \Kendo\UI\Spreadsheet('spreadsheet');
    $spreadsheet->attr('style', 'width: 100%;');
    $spreadsheet->additional_jquery_code = 'var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
                $(".download").click(function () {
                    $("#download-data").val(JSON.stringify(spreadsheet.toJSON()));
                });';

    Now, the spreadsheet data are POSTed to the PHP script that processes the changed data.

  3. UI for ASP.NET AJAX banner
Back to Top