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

Bind a cell to a dropdown list on selection of the same row's another dropdown list's change event?

5 Answers 341 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Iffat
Top achievements
Rank 1
Veteran
Iffat asked on 26 Feb 2021, 12:10 AM

Dear Kendo team,

Is there a way to bind a cell to a dropdown list on selection of the same row's another dropdown list's change event? 

I have attached a screenshot. On selection of B3's dropdown list, I need to generate a dynamic dropdown list in C3 column.

Can you help me with an example code? I tried to search this in the forum, but couldn't find the exact answer.

Thanks in advance :)

 

Best Regards

Iffat

5 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 02 Mar 2021, 03:13 PM

Hi Iffat,

I would suggest you subscribe to the change event of the Spreadsheet. In the event handler, you could check the changed cell. Then, you could use the Range validation method to set validation with dataType list to another cell. Below is a sample implementation:

change: function(e){
              
              if(e.range._ref.col ==1 && e.range._ref.row == 0 ){
                setTimeout(function() {
                  var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
                  var sheet = spreadsheet.activeSheet();
                  sheet.range("D1").value('Changed');
                  sheet.range("D1").validation({
                    dataType: "list",
                    showButton: true,
                    comparerType: "list",
                    from: '"First, Second, Third"',
                    allowNulls: true,
                    type: "reject"
                  });	
                });
              }
            },

Here is a Dojo example where the described above is demonstrated. I hope you will find it helpful.

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/.

0
Iffat
Top achievements
Rank 1
Veteran
answered on 11 Mar 2021, 03:10 AM
Thanks Neli, I appreciate your help. Is there any chance you have a working demo to bind the dropdown with ajax api call?
0
Aleksandar
Telerik team
answered on 15 Mar 2021, 02:20 PM

Hi Iffat,

Loading dynamically the options for the validation DropDownList is currently not supported. We have a Feature Request on this functionality here https://feedback.telerik.com/kendo-jquery-ui/1360250-spreadsheet-validation-dropdown-data-binding and I have added a vote on it on your behalf. If the community shows interest in this feature we will consider it for implementation in a future release.

Regards,
Aleksandar
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
Iffat
Top achievements
Rank 1
Veteran
answered on 23 Mar 2021, 05:38 AM

Thanks. 

My next question would be, if it only supports a comma separated string, how does it track which value (we need to get the Id of that selected value of dropdown list)is selected on saving the sheet in database?

If it's not possible and I need to use a custom cell editor, how to get selected item's id onsave?

Thanks in advance
Iffat

0
Aleksandar
Telerik team
answered on 25 Mar 2021, 02:51 PM

Hello Iffat,

When you use a comparerType:list you can pass a comma separated list, that is to be used as values, but not a list of objects. Even if you implement a custom editor the selected value of the editor needs to be set as a value of the cell. You can still use the change event to get the value of the changed range, for example https://dojo.telerik.com/atuHaWuF

Regards,
Aleksandar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Spreadsheet
Asked by
Iffat
Top achievements
Rank 1
Veteran
Answers by
Neli
Telerik team
Iffat
Top achievements
Rank 1
Veteran
Aleksandar
Telerik team
Share this question
or