I'm using Kendo Grid with POPUP editing.
On edit POPup I'm having a textbox like below.
@Html.TextBoxFor(model => model.FirstName, new { style = "width:175px" })
Then I set this textbox value using Jquery
$("#FirstName").val("my name");
When I submit the popup to save the values it does not pass these values to controller. However, if I type a value on the textbox, then it works fine.
Why is it not working with the values set through Jquery?
There is a simpler solution:
$("#FirstName").val("my name").trigger("change");
Value set directly on editor pop-up / templates from jquery for some old reasons is not updating the model. I also faced the same issue, below is my solution.
var uid = $(".k-edit-form-container").closest("[data-role=window]").data("uid"),
model = $("#myGrid").data("kendoGrid").dataSource.getByUid(uid);
model.set("FirstName", "my name");
Do let me know if this is not what you were looking for!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With