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

Remove All Data from sheet

19 Answers 966 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 12 Jan 2017, 07:57 AM

Hi,

Is there a method to clear all data from a specified sheet?

Thanks!

19 Answers, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 13 Jan 2017, 02:54 PM
Hi Marc,

You can use the following approach that is not part of the documented public API:

http://dojo.telerik.com/UtajU

... or this one that uses documented methods and options only:

http://dojo.telerik.com/IHURo

Alternatively, you can remove a given sheet via the removeSheet() method, and insert an empty one (or a sheet with the desired options) via the insertSheet() method:

http://dojo.telerik.com/UtajU/2

I hope this helps.

Regards,
Dimiter Topalov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Marc
Top achievements
Rank 1
answered on 13 Jan 2017, 03:03 PM

Hey Dimiter!

In the undocumented example, what does kendo.spreadsheet.SHEETREF represent? Can I use spreadSheet.options.sheets[0]?

Thanks!

Marc

0
Marc
Top achievements
Rank 1
answered on 16 Jan 2017, 08:09 AM

Also when using SHEETREF, I get the following:

 

angular.js:21778 RangeError: Invalid array length
    at init.values (kendo.all.js:106562)
    at init._sheetChange (kendo.all.js:127561)
    at init.trigger (kendo.all.js:137)
    at init.triggerChange (kendo.all.js:108951)
    at init.batch (kendo.all.js:109812)
    at init.clear (kendo.all.js:106638)
    at Object.fn (current-stage-sku-line-results.js:110)
    at k.$digest (angular.js:21778)
    at k.$apply (angular.js:21778)
    at h (angular.js:21778)

My statement is this: spreadSheet.activeSheet().range(kendo.spreadsheet.SHEETREF).clear();

Thanks!

0
Marc
Top achievements
Rank 1
answered on 16 Jan 2017, 08:16 AM

Sorry I forgot to mention before - I am using the spreadsheet with a remote datasource, so I think what I'm really looking for is a way to clear all the data from the dataSource.

Thanks!

0
Accepted
Dimiter Topalov
Telerik team
answered on 16 Jan 2017, 01:58 PM
Hi Marc,

Thank you for clearing up the desired functionality. To "clear" all the data from the dataSource, call the dataSource.data() method, passing it an empty array:

http://dojo.telerik.com/aQORa

As for the kendo.spreadsheet.SHEETREF - it is used internally, and basically creates a range, representing the whole sheet. You can find the specific implementation in our source code (kendo.spreadsheet.js file), if you are interested.

Regards,
Dimiter Topalov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Johnson
Top achievements
Rank 1
answered on 07 Feb 2018, 09:06 AM

Hi Dimiter,

How to clear the applied "Filter" condition for the entire spreadsheet....

Best Regards...

0
Veselin Tsvetanov
Telerik team
answered on 08 Feb 2018, 01:44 PM
Hi Johnson,

To clear the applied filter condition for the entire Spreadsheet Sheet, you will first need to get reference to the range, that represents the entire Sheet:
var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
var sheet = spreadsheet.activeSheet();
var rowsCount = sheet._rows._count;
var columnsCount = sheet._columns._count;
var sheetRange= sheet.range(0, 0, rowsCount, columnsCount);

Then you could reset the filter condition:
sheetRange.filter(false);
sheetRange.filter(true);

Regards,
Veselin Tsvetanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Johnson
Top achievements
Rank 1
answered on 12 Feb 2018, 06:54 AM

Hi Veselin,

thank you very much ..its working perfectly ..

Best Regards...

 

 

0
Johnson
Top achievements
Rank 1
answered on 12 Feb 2018, 08:42 AM

Hi Veselin,

How tp get the total rows count after "filter" is applied, is there Jquery event while filtering ..

Best Regards,

0
Johnson
Top achievements
Rank 1
answered on 13 Feb 2018, 03:56 AM

Hi Veselin,

How to add ActionLink to the spreadsheet row-column.. please advice ...

Best Regards,

0
Neli
Telerik team
answered on 13 Feb 2018, 01:02 PM
Hi Johnson,

I am afraid that 'filtering' event in Kendo UI Spreadsheet is not supported. Also there is no built in functionality for adding ActionLink to row or column. 

I would suggest you to log your ideas in our Feedback Portal. This way the other users can vote for the ideas. The issues which gain more popularity will be considered for future implementation. 

Regards,
Neli
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Johnson
Top achievements
Rank 1
answered on 14 Feb 2018, 05:02 AM

Hi Neli,

Thank you very much for your details.. very disappointing ..could you please advice me to get the spread sheet selected row column value  in Jquery .. 

Best Regards..

0
Johnson
Top achievements
Rank 1
answered on 14 Feb 2018, 11:32 AM

Hi Neli,

I managed to get the selected value..thank you..  

Best Regards,

0
Neli
Telerik team
answered on 15 Feb 2018, 04:10 PM
Hello Johnson,

After a discussion with our developers I can suggest you a custom solution in order to find the total rows in the Spreadsheet after filtering.
You can check the total rows count in the Spreadsheet by using the following
var totalCount = this.view._sheet.toJSON().rows.length;

Then, for every row you can check if it is hidden or not and increase/decrease respective counters:
for (var i = 0; i < this.view._sheet.toJSON().rows.length; i++) {
if (this.view._sheet.isHiddenRow(i)) {
   totalCount--;
    hiddenRows++
}
}

I hope you will find the linked Dojo example helpful

Regards,
Neli
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Johnson
Top achievements
Rank 1
answered on 16 Feb 2018, 05:31 AM

Hi Neli,

Could you please give me the sample in Razor syntax ...

Best Regards..

0
Neli
Telerik team
answered on 19 Feb 2018, 02:41 PM
Hello Johnson,

There will not be huge difference if you use Kendo UI for jQuery widgets or the ASP.NET MVC wrappers. You will declare the Spreadsheet widget in a different way. You can take a look of the Spreadsheet Demos for MVC on the following link. 

In both cases you will need to include the following script: 
<script>
    kendo.spreadsheet.Controller.fn.onCommandRequest = function (e) {
        if (e.command) {
        this._execute(e);
      } else {
        this._workbook.undoRedoStack[e.action]();
      }
      if (e.command === "ApplyFilterCommand") {
        var totalCount = this.view._sheet.toJSON().rows.length;
        var hiddenRows = 0
        alert(totalCount-1);
        for (var i = 0; i < this.view._sheet.toJSON().rows.length; i++) {
            if (this.view._sheet.isHiddenRow(i)) {
            totalCount--;
            hiddenRows++
          }
        }
                
        alert('hidden: ' + hiddenRows);
      }
    }   
</script>


Regards,
Neli
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
samk
Top achievements
Rank 1
answered on 23 Jul 2018, 07:17 PM
This will clear everything from the spreadsheet including the backgrounds. Is there a way to clear just the cell values?
0
Neli
Telerik team
answered on 25 Jul 2018, 02:30 PM
Hello,

Could you please describe the issue in more details? The sample provided previously is used to show the total count of hidden rows when the data in the Spreadsheet is filtered. The provided script does not affect the styles of the widget so no background is cleared. Here is a screencast. Please let me know if I am missing something.


Regards,
Neli
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
samk
Top achievements
Rank 1
answered on 25 Jul 2018, 03:06 PM
Please discard my comment. I found a way to clear the data. Thanks!
Tags
Spreadsheet
Asked by
Marc
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Marc
Top achievements
Rank 1
Johnson
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Neli
Telerik team
samk
Top achievements
Rank 1
Share this question
or