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

MVC model does not update when data populated through jQuery

1 Answer 1609 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 03 Jun 2016, 03:45 PM

I'm using a kendo grid popup editor. I have a custom template (partial view) for edit. I have a drop down and on change event, I'm populating a TextBox. The problem is when I am sending the model to the controller, the TextBox value is null. It's not updating the model with the populated value. Any idea why?

@(Html.Kendo().DropDownListFor(w => w.AddressID)

.DataTextField("Name")

.DataValueField("AddressID")

.DataSource(source =>{ source.Read(read =>{ read.Action("GetAddressType", "DataSource")

.Data("filterAddressTypes");})

.ServerFiltering(true);})

.CascadeFrom("CodeIDAddressType")

.Events(e => e.Change("addressSubType"))

)

 

@Html.TextBoxFor(model => model.AddressLine1)

On an AJAX done function, I'm populating the value.
$("#AddressLine1").val(response.AddressLine1)

I can see the new value in the text box but when submitted, it sends null to the controller. If I enter the value in the AddressLine1 field instead of populating, it sends the entered value to the controller.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 07 Jun 2016, 08:46 AM
Hello Ram,

To help the grid to "capture" the new value you've set manually using script, you can try using the following approach:
http://www.telerik.com/forums/textbox-value-set-by-jquery-is-empty-on-save#Hb80Zx7l802iIjk_CUFC1A

I hope this will prove helpful.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Ram
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or