hi,
it is a follow up to: link
I have a grid with custom editor:
editor:
I am trying to add a new record. So I click add new enter values select value form drop down. That is when I encounter my first problem - I can't select first value - I can select it but is not recognised as selection and when cell looses focus I am loosing value.
Than I press Save and data is sent to odata controller
Here I am saving record to db. Following this article I had to mark drop down data as unchanged to make sure EF will not try to reinsert values. Then I am sending created entity back to client.
As I am using web api odbc v3 I had to make some changes to schema, data value
And that is when my second problem starts - returned data has no Application property and that is what my field template is expecting - I have only ApplicationRef which is a foreign key.
How can I make sure that my new row will display a correct value in drop down list when new record is saved and made a round trip to server and back?
Please find sample project: here
it is a follow up to: link
I have a grid with custom editor:
{ field: "Application", title: "Owned By", width: "120px", editor: applicationDropDownEditor, template: "#=Application.ApplicationName#" }editor:
var applicationDataSource = { type: "odata", transport: { read: { url: "odata/Sys_Application", dataType: "json", type: "GET" }, }, schema: { data: "value", total: "count" }, } function applicationDropDownEditor(container, options) { $('<input required data-bind="value:' + options.field + '"/>') .appendTo(container) .kendoDropDownList({ autoBind: false, dataTextField: "ApplicationName", dataValueField: "ApplicationRef", dataSource: applicationDataSource }); }I am trying to add a new record. So I click add new enter values select value form drop down. That is when I encounter my first problem - I can't select first value - I can select it but is not recognised as selection and when cell looses focus I am loosing value.
Than I press Save and data is sent to odata controller
// POST: odata/Entities public async Task<IHttpActionResult> Post(Entity entity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Entry(entity.Application).State = EntityState.Unchanged; db.Entities.Add(entity); await db.SaveChangesAsync(); return Created(entity); }Here I am saving record to db. Following this article I had to mark drop down data as unchanged to make sure EF will not try to reinsert values. Then I am sending created entity back to client.
As I am using web api odbc v3 I had to make some changes to schema, data value
schema: { data: function (data) { if (data.value) { return data.value; } delete data["odata.metadata"]; return [data]; }And that is when my second problem starts - returned data has no Application property and that is what my field template is expecting - I have only ApplicationRef which is a foreign key.
How can I make sure that my new row will display a correct value in drop down list when new record is saved and made a round trip to server and back?
Please find sample project: here