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

How to change value of Textbox in Editor Template for cell. Value provided to server differs to displayed value.

3 Answers 303 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Malcolm
Top achievements
Rank 1
Malcolm asked on 01 Jul 2013, 01:12 PM
Dear KendoUI Team!
I hope you can help me out. I want to update some Editor Templates from the old Telerik Controls. I am using ASP.Net MVC 4.

My Editor Template looks like this

@model string
@using System.Collections
<div style="white-space:nowrap;">
 
 
    @Html.TextBoxFor(m => m, new { onclick = "setInvisible(\"SplitCountryList#=Rid#\")", onfocus = "setInvisible(\"SplitCountryList#=Rid#\")", id = "CoPrefSplit#=Rid#" })
    <button id="SplitCountryDisplay" onclick="setVisibleAndFocus('\\#SplitCountryList#=Rid#','\\#SplitCountryCombo-input')" style="background-color:White; width: 20px; height:22px; font-size: 6pt">...</button>
</div>
 
<div id="SplitCountryList#=Rid#" style="position: absolute; overflow:visible; width:250px; z-index:99; margin-top: 0px; visibility:hidden;">
@(Html.Kendo().ComboBoxFor(m => m)
        .Name("SplitCountryCombo#=Rid#")
        .BindTo(new SelectList((IEnumerable)ViewData["Countries"], "Code", "DisplayName"))
        .HtmlAttributes(new {@ArticleID = "#=Rid#"})
        .Filter(FilterType.Contains)
        .Events(events => events
            .Change("onSplitCountryChanged")
        )
    )
</div>

What I want to do is to set the value of the Textbox in the Change Event of the Combo-Box. My Approach is using .val()

$(elementName).val(e.sender.dataItem().Value);

The value displayed in the Textbox is changed then. BUT: The value transfered to the server is the old value of the Textbox.

Example:
The field has the value "US".  I edit the row.  I change the value to "CN" using the Combobox. "CN" is now displayed in the textbox in edit mode. When I want to update the row, "US" is provided as the value for the field in the model.

Is there a way to make kendoUI transfer the values that are displayed?

brgds
Malcolm Howlett

3 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 03 Jul 2013, 12:50 PM
Hi Malcolm,

 
From the provided information it's not clear for us what is the exact setup that you have  - could you please provide small example project that reproduced the issue? This would help us pinpoint the exact reason for this behavior.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Malcolm
Top achievements
Rank 1
answered on 09 Jul 2013, 10:20 AM
Attached you find a simple project that shows the problem.
Try the following:
- Edit a row
- Klick the button (...) in the country2 colum
- You will now see a combobox
- Choose a different value for country2 than 'C1' using the combox!
- You will see the new value in the Textbox for country2
- Set a breakpoint in the Update method of the home controller
- Update the row.
- You will see that the value provided to the controller for country2 is still 'C1'. But the value displayed in the Textbox ist not 'C1'.
0
Vladimir Iliev
Telerik team
answered on 11 Jul 2013, 07:46 AM
Hi Malcolm,

After reviewing the provided project it seems that the issue related to not correctly updating the underlying row model on change of the DropDownList. On each change of the DropDownList you should find the dataItem of the current row and set the current value using the set method. 

For convenience I updated the provided project with the above change and attached it to the current thread.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Malcolm
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Malcolm
Top achievements
Rank 1
Share this question
or