I am currently using WebAPI and KendoUI (drop down in this example). When I need to the object to the API I grab the object out of the data source. To get the selected item I use:
var dataItem= $("#dropDown").data("kendoDropDownList").dataItem();
Then to make the object valid I have to remove kendo's ID like so:
delete dataItem.$id
After this I can JSON.stringify the object to pass to the API via ajax:
$.ajax({
type: "PUT",
url: BASE + "Api/MyController",
data: JSON.stringify(dataItem),
contentType: "application/json",
success: function () {
alert("Success");
},
error: function (result) {
alert("failed");
}
});
Is this bad practice? Is there a better way of getting the object from the data source instead of deleting kendoui's $id every time?