chamara
chamara

Reputation: 12709

Set Kendo Grid POPUP editor values using Jquery

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?

Upvotes: 6

Views: 4272

Answers (2)

mrmashal
mrmashal

Reputation: 1883

There is a simpler solution:

$("#FirstName").val("my name").trigger("change");

Upvotes: 6

D_Learning
D_Learning

Reputation: 1023

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!

Upvotes: 5

Related Questions