Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 604
chamara Avatar asked Jul 16 '14 11:07

chamara


2 Answers

There is a simpler solution:

$("#FirstName").val("my name").trigger("change");
like image 125
mrmashal Avatar answered Sep 27 '22 23:09

mrmashal


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!

like image 32
D_Learning Avatar answered Sep 27 '22 22:09

D_Learning