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

Popup editing with dropdownlist not working properly

6 Answers 848 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mathew
Top achievements
Rank 1
Mathew asked on 27 Feb 2013, 09:24 AM
The dropdown value when reflected back from the popup edit is showing [Object][Object]
Following shows the code
  http://jsbin.com/eyebub/4/edit

6 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 01 Mar 2013, 08:30 AM
Hello Mathew,

The column field is TypeValue, but the model is defined as Type instead of TypeValue. This is the reason for the behavior.

Here is an updated sample:
http://jsbin.com/eyebub/8/edit

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tinju
Top achievements
Rank 1
answered on 01 Mar 2013, 09:03 AM
Thanks for help 
But i have another question
On the code u send when i replaced 
<input name="TypeValue" 
data-bind="value:TypeValue" 
data-value-field="TypeValue" 
data-text-field="TypeValue" 
data-source="dropDownDataSource" 
data-role="dropdownlist" />
with this
<input name="TypeValue" 
data-bind="value:Value" 

I was able to get  
grid.dataItem(grid.select()).Value.TypeValue with the same value on save 

How is this working as Value is not a feild in the grid and in the model or source of the grid?
0
Nikolay Rusev
Telerik team
answered on 04 Mar 2013, 01:34 PM
Hello Tinju,

Setting the following attribute: data-bind="value:Value" means that the DOM will populate from the value of Value field in the model and the same field will be updated on change of the DOM element.
 

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ruben
Top achievements
Rank 1
answered on 05 Oct 2015, 06:54 PM

This example only works when dropdown has same text and value. In real life they different.

    var datavalue = [];
    datavalue.push({ TypeValue: "1", TypeText: "New" });
    datavalue.push({ TypeValue: "2", TypeText: "Important" });
    datavalue.push({ TypeValue: "3", TypeText: "Remark" });
    datavalue.push({ TypeValue: "4", TypeText: "Complaint" }); 

Do you know how to handle this case?

Thank you.

http://jsbin.com/tobucicuci/edit?html,output​

0
Nikolay Rusev
Telerik team
answered on 07 Oct 2015, 09:00 AM

Hello Ruben,

 

There are various ways to implement this, however as both fields TypeValue and TypeText are part of the Grid data item you could do the following - track for changes in TypeValue field and update the other TypeText field.

 

Example - http://dojo.telerik.com/@rusev/EWEJe

 

Important bits from edit event handler:

 edit: function (e) {            
            var typeValueDropDown = $("[name=TypeValue]").data("kendoDropDownList");
            
            e.model.bind("set", function(e) {
              if (e.field == "TypeValue") {
                this.set("TypeText", typeValueDropDown.text());
              }
            });
},

 

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ruben
Top achievements
Rank 1
answered on 07 Oct 2015, 01:41 PM
Thank you, Nikolay. It works like a charm.
Tags
Grid
Asked by
Mathew
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Tinju
Top achievements
Rank 1
Ruben
Top achievements
Rank 1
Share this question
or