How to overwrite the Combo box setvalue function

Posted by muthu99525 on 07-Nov-2017 04:25

In this case for combo box I have multiple optionId, Option description ... First item has Option ID:"", option description:"select"...Initial loading it is working fine. later the option description for the null Id is undefined ... I enabled the value primitive also... 

Reference :vm.setValue = function(newModel, oldModel)

All Replies

Posted by muthu99525 on 09-Nov-2017 06:37

Any one can help on this?.how can i watch the change value of combo box from controller.pubilc.js?

Posted by egarcia on 09-Nov-2017 07:21

Hello,

Could you provide more information on the issue that you are trying to solve?

Perhaps sample code could help to show the issue.

Are you seeing this issue with a view created using the blank template?

Can you reproduce the issue using the Dojo?

docs.telerik.com/.../combobox

I hope this helps.

Posted by muthu99525 on 10-Nov-2017 01:20

replicating the issue in Dojo is a long process... i am getting this error KUIB2 grid view.. i have overwrite the below function vm.setValue = function(newModel, oldModel) {

                       if (vm.options.dataValueField  && typeof newModel !== 'object') {                                

                        var value = vm.options.valuePrimitive ? newModel : newModel(vm.options.dataValueField);

                             }

                             if(typeof newModel == 'object'){                

                        var value = vm.options.valuePrimitive ? "Select" : newModel(vm.options.dataValueField);

                                }        

                     vm.widget.value(value);  

                   }

this is solution for the issue. but this code in combo box index.js which auto generated... 

DataValueField DataTextFeild
Select
1 apple
2 orange

Kendo doest not read the text value of null ID.. hope this will help... 

Posted by egarcia on 16-Nov-2017 10:21

Hello,

Thank you for the additional information.

I have tried to reproduce the issue and I have seen some elements of what you described. However, I have not been able to reproduce the issue as such.

I am able to see the description for the item with a blank data value.

Since you pointed out to the vm.setValue() code, I looked into ways to override setValue(): change the value based on certain events or use a  template() function. (There is also the option of custom component new in KUIB 2.0.1.)

The only issue that I was able to see was that without the code that you listed, the ComboBox would show "[object Object]" when it is first displayed on the screen.

This particular issue could be solved by using a valueMapper function.

Example:

       this.$components.combobox0.options.virtual = {

           valueMapper: function (options) {

               if (options.value && !options.value.State) {

                   options.success(0);

               } else {

                   options.success([]);

               }

           }

       };

I hope this helps,

Edsel

Posted by muthu99525 on 22-Nov-2017 06:20

Thank you so much .. the value mapper is used for initial time only ... apologies to eating your time . here please imagine the below scenario ..

1. I have grid of 5x5.- column 4 is a payment option "combo box"

2. after clicking the edit button it opens the pop up with editable combo box - default value is "Select".

3. I am selecting "new payment ". then cancel changes.

4. Now if i am coming to grid -> new  row -> edit , the new combo box has the value "New Payment " instead of "Select"....

because the below code throws value = "undefined". so its take the previous value. "New Payment "

My table 

Data Value Field : ID  Data Text Field : payment mode
Select
1 New Payment
old payment
3 settled payment

So Particularly i want override the Setvalue method in index.js as said before...

Thanks again

This thread is closed