I am having trouble understanding what exactly is going on here in the snippet below.
I am attempting to upload a file to my web view spreadsheet but not save the file. What is going on with the ProxyURL, the "/kendo-ui/content/web/spreadsheet/products.json" and the "saveUrl: "/kendo-ui/spreadsheet/Upload". What do I need to change to allow the functionality to work locally for me while I am testing.
In a gist. I want to, Upload a file, save the file, display the file, and export the file. I can't figure this out exactly.
$(
function
() {
$(
"#spreadsheet"
).kendoSpreadsheet({
excel: {
// Required to enable Excel Export in some browsers
}
});
var
spreadsheet = $(
"#spreadsheet"
).data(
"kendoSpreadsheet"
);
$.getJSON(
"/kendo-ui/content/web/spreadsheet/products.json"
)
.done(
function
(sheets) {
spreadsheet.fromJSON({ sheets: sheets });
});
var
ALLOWED_EXTENSIONS = [
".xlsx"
,
".csv"
,
".txt"
,
".json"
];
$(
"#upload"
).kendoUpload({
async: {
saveUrl:
"/kendo-ui/spreadsheet/Upload"
},
multiple:
false
,
localization: {
"select"
:
"Select file to import..."
},
select:
function
(e) {
var
extension = e.files[0].extension.toLowerCase();
if
(ALLOWED_EXTENSIONS.indexOf(extension) == -1) {
alert(
"Please, select a supported file format"
);
e.preventDefault();
}
},
success:
function
(e) {
// Load the converted document into the spreadsheet
spreadsheet.fromJSON(e.response);
}
});
$(
".download"
).click(
function
() {
$(
"#download-data"
).val(JSON.stringify(spreadsheet.toJSON()));
$(
"#download-extension"
).val($(
this
).data(
"extension"
));
});
});