Can I add a range of comments to Kendo Spreadsheet similar to the way you can add a range of values.

1 Answer 20 Views
Spreadsheet
Daniel
Top achievements
Rank 1
Iron
Daniel asked on 18 May 2022, 01:55 PM

Adding a range of values looks like this.

 

values2 is comma separated string of values enclosed in []

 

var range = spreadsheet.Range(A1:Z1);

range.values(values2)   This fills each cell with one comma separated value from the string and works well.

range.comment(values2) This fills every cell in the range with the entire string of values2. It does not parse in the same way as range.Values.

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 23 May 2022, 12:19 PM

Hi Daniel,

The behavior will be similar if for example, you are using the value method instead of the values as demonstrated in the Dojo linked here.

The comment method accepts a single string that will be used as a comment to the specified range. it does not split the string to multiple substrings. 

Let me know in case you have additional questions or need further assistance.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Daniel
Top achievements
Rank 1
Iron
commented on 02 Jun 2022, 12:58 PM

Sorry, I left out one detail.. Before adding the values to the range, I create an array from the comma delimited string like this:

var arr = values.split(',');

then range.values(arr);

This works great for cell values but not for cell comments. For comments, it puts the entire string[] in each Cell Comment for the entire range.

Daniel
Top achievements
Rank 1
Iron
commented on 02 Jun 2022, 01:26 PM

Ignore my previous comment. Here is the full solution. The difference is that unlike the Dojo, I use range.values not range.value

<div id="spreadsheet"></div>
    <script type="text/javascript" charset="utf-8">

$("#spreadsheet").kendoSpreadsheet();

var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");

      var myvalues = [];
var sheet = spreadsheet.activeSheet();

var values = "A, B, C";
      var arr = values.split(',');
      myvalues.push(arr);

sheet.range("A1:C1").values(myvalues);
    </script>
Neli
Telerik team
commented on 07 Jun 2022, 08:48 AM

Hi Daniel,

I am glad to hear that the issue is resolved. Indeed, for setting values to multiple cells the values method should be used.

For convenience to the other users in the forum here is a runnable Dojo example with the code snippet from your reply. 

Regards,

Neli

Daniel
Top achievements
Rank 1
Iron
commented on 09 Jun 2022, 01:01 PM

Thanks for that but I want to point out one error in your code. You are still using Range.value instead of value(s)., resulting in each cell getting all three letters. If you change value to values, it works correctly. I'm sure you know this and it was just a typo.

 

Thanks

Neli
Telerik team
commented on 14 Jun 2022, 08:55 AM

Hi Daniel,

Thank you very much for poitning to the issue. Indeed this is a typo, I saved the wrong version of the Dojo example after testing. Below you will find the modified version where the values method is used:

https://dojo.telerik.com/@NeliKondova/UgeZeHeG

Regards,

Neli

Tags
Spreadsheet
Asked by
Daniel
Top achievements
Rank 1
Iron
Answers by
Neli
Telerik team
Share this question
or