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

Update spreadsheet datasource model

6 Answers 14 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
c0dr.64d1
Top achievements
Rank 1
Veteran
c0dr.64d1 asked on 31 Jan 2021, 02:51 PM

Hi all,

I've created a spreadsheet app that uses a dropdown list in a similar fashion to this: http://dojo.telerik.com/@nenchef/ojEWU/3

I would like to update the data in the spreadsheet when I make a selection in the dropdown. The problem I'm having is that I can't seem to trigger a

read or the model's accessor methods. The best I've been able to do is trigger a change on the spreadsheet like this:

                    model.bind("change", function (e)
                    {
                            var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
                            spreadsheet.trigger("change");

                    });

Any help appreciated.

Best

 

6 Answers, 1 is accepted

Sort by
0
Accepted
Petar
Telerik team
answered on 04 Feb 2021, 07:12 AM

Hi c0dr.64d1,

Here is a Dojo example that shows how we can use the change event of the DropDownList to change a value in the Spreadsheet. The changes I made in the project you've sent me are in the "el" definition as follows:

$("<div data-visible='true' data-role='window' data-modal='true' data-resizable='false' data-title='Select item '>" +
                       "  <div data-role='dropdownlist' data-bind='value: value, source: products, events: {change: onChange }' data-text-field='ProductName'></div>" +
                       "  <div style='margin-top: 1em; text-align: right'>" +
                       "    <button style='width: 5em' class='k-button' data-bind='click: ok'>OK</button>" +
                       "    <button style='width: 5em' class='k-button' data-bind='click: cancel'>Cancel</button>" +
                       "  </div>" +
                       "</div>");

Then in the model, we have the following function:

onChange: function () {
     var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
     var activeSheet = spreadsheet.activeSheet();
     activeSheet.range("C5").value("111111111");
}

I hope the above demonstrates what you want to implement in your application. 

Regards,
Petar
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/.

0
c0dr.64d1
Top achievements
Rank 1
Veteran
answered on 06 Feb 2021, 11:59 AM
Very helpful!! thank you @petar
0
c0dr.64d1
Top achievements
Rank 1
Veteran
answered on 06 Feb 2021, 01:16 PM
I have one other issue..I've defined an onChange function that isn't part of the model that is being triggered because the spreadsheet is updating. in other words i'm handling a change to my spreadsheet's datasource. is there a way to capture the sender? that way I can tell the difference between the change to the sheet from the dropdownlist as opposed to a change made by editing the spreadsheet itself.
0
Petar
Telerik team
answered on 10 Feb 2021, 11:22 AM

Hi c0dr.64d1,

In general, all events triggered by our components have a "sender" property in their event handler. Maybe you don't expect this answer but this is what I can share, based on the available information. 

To help you with the issue, I will need a runnable example that implements your custom logic of the DataSource change event. Can you use the Dojo example I've sent you as a basis and add your custom logic to it? Having the whole context, I can think about a possible solution for your issue. 

Last but not least, I can see that you have a Priority support license. Our usual response time for the forum threads is 72 hours. If you submit a support ticket(your plan allows it), the response time will be 24 hours and thus we can speed the communication up. 

Another benefit of the Support ticket is that your implementation is not publicly shared if you have concerns about this. If you decide to submit a support ticket, please share the requested runnable example in it. You can also add other details that you think will be useful for resolving the issue. 

Regards,
Petar
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/.

0
c0dr.64d1
Top achievements
Rank 1
Veteran
answered on 11 Feb 2021, 07:40 PM
ok, thanks
0
Petar
Telerik team
answered on 15 Feb 2021, 03:47 PM

Hi c0dr.64d1,

Based on the communication in support ticket #1506694, I will close this thread. 

Regards,
Petar
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/.

Tags
DropDownList
Asked by
c0dr.64d1
Top achievements
Rank 1
Veteran
Answers by
Petar
Telerik team
c0dr.64d1
Top achievements
Rank 1
Veteran
Share this question
or