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

How to clear the spreadsheet but not the headers

2 Answers 186 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 17 Dec 2015, 10:08 AM
Keno spreadsheets are new and the documentation is very scarce.

I'm trying to do something relatively simple.

I have a spreadsheet with stylized headers like this:

    this.sheetsHeader = [
                {
                    name: "ProductsEntry",
                    rows: [
                        {
                            height: 15,
                            cells: [
                                {
                                    value: "Name",
                                    bold: "true",
                                    background: "#00435e",
                                    textAlign: "center",
                                    color: "white",
                                    fontSize: 14,
                                }, {
                                    value: "Type",
                                    bold: "true",
                                    background: "#00435e",
                                    textAlign: "center",
                                    color: "white",
                                    fontSize: 14,
                                },
                                {
                                    value: "Currency",
                                    bold: "true",
                                    background: "#00435e",
                                    textAlign: "center",
                                    color: "white",
                                    fontSize: 14,
                                },
                                {
                                    value: "Rate",
                                    bold: "true",
                                    background: "#00435e",
                                    textAlign: "center",
                                    color: "white",
                                    fontSize: 14
                                },
                                {
                                    value: "StartDate",
                                    bold: "true",
                                    background: "#00435e",
                                    textAlign: "center",
                                    color: "white",
                                    fontSize: 14,
                                }
                            ]
                        }
                    ],
                    columns: [
                        { width: 200 },
                        { width: 200 },
                        { width: 90 },
                        { width: 90 },
                        { width: 110 }
                    ]
                }
            ];


and that gets initialized the normal way:

        $("#spreadsheet").kendoSpreadsheet({
            toolbar: false,
            sheetsbar: false,
            sheets: that.sheetsHeader
        });

Then later I have an event that clears the spreadsheet but I want to leave the headers intact.

If I do this:

    var sheet = spreadsheet.activeSheet();
    sheet.range(kendo.spreadsheet.SHEETREF).clear();

It wipes out the headers and leaves the sheet entirely empty.

I tried re-adding the headers in many different ways but nothing worked for me.

Aftear clearing the spreadsheet I tried:

     sheet.fromJSON(that.sheetsHeader[0].rows);

I also tried deleting the sheet and re-adding it:

     spreadsheet.removeSheet(0);
     spreadsheet.insertSheet(that.sheetsHeader);

Nothing really worked so far and there's no documentation for this sort of scenario. Any ideas?

2 Answers, 1 is accepted

Sort by
0
Darren
Top achievements
Rank 1
answered on 17 Dec 2015, 01:08 PM
Never mind managed to get it to work.

Some more documentation would be good though. I'm spending a lot of time trying to find the "trick" to getting everything to work
0
Jim
Top achievements
Rank 1
answered on 01 Mar 2016, 10:23 PM
Hey Darren, can you tell me how you accomplished this? I too am having issues clearing out the sheet without losing my headers.
Tags
Spreadsheet
Asked by
Darren
Top achievements
Rank 1
Answers by
Darren
Top achievements
Rank 1
Jim
Top achievements
Rank 1
Share this question
or