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

Bind Spreadsheet with imported excel

1 Answer 196 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Omar
Top achievements
Rank 1
Omar asked on 29 Sep 2016, 07:09 PM

I have a Spreadsheet which already Bind to an object (see below code). I want to open a file (import) and Bind it with my existing binding.

@(Html.Kendo().Spreadsheet()
.Name("spreadsheet")
.Sheetsbar(false)
.Toolbar(x => x.Data(false).Insert(false))
.HtmlAttributes(new { style = "width:100%;" })
.Rows(5000)
.Events(e => e.ExcelImport("ImportProduct"))
.Sheets(sheets =>
{
sheets.Add()
.Name("Product")
.DataSource<MyCompany.DTO.Logistics.Planning.ProductSearchResultDTO>(ds => ds
.Ajax()
.Batch(true)
.Read(r => r.Action("ProductBulkSearchResults", "Logistics").Data("getCriteria"))
.Update(u => u.Action("ProductBulkUpdate", "Logistics").Data("getCriteria"))
.Events(e => e.Change("onChange"))
.Model(m =>
{
m.Id(p => new { p.ProductID, p.ORGID });
})
)
.Columns(columns =>
{
columns.Add().Width(100);
columns.Add().Width(415);
columns.Add().Width(0);
columns.Add().Width(0);
columns.Add().Width(145);
})
;
})
)

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 03 Oct 2016, 03:13 PM
Hello Omar,

A file can be imported in the Spreadsheet through the fromJSON method, which you can see in action in the following demo. As you can see in the Upload's success handler:
success: function (e) {
                // Load the converted document into the spreadsheet
                spreadsheet.fromJSON(e.response);
            }

the data is loaded from the response and it does not use the existing binding. Calling this method simple removes all the existing data and loads the one saved in the response. So binding the Spreadsheet to an object and importing a file are two different approaches of loading data.

Regards,
Ivan Danchev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Spreadsheet
Asked by
Omar
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or