This is a migrated thread and some comments may be shown as answers.

How to post Spreadsheet data to php script

1 Answer 118 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Reinier
Top achievements
Rank 1
Reinier asked on 04 Nov 2016, 05:32 PM

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.

1 Answer, 1 is accepted

Sort by
0
Reinier
Top achievements
Rank 1
answered on 06 Nov 2016, 04:14 PM

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.

Tags
Spreadsheet
Asked by
Reinier
Top achievements
Rank 1
Answers by
Reinier
Top achievements
Rank 1
Share this question
or