Note that there are some explanatory texts on larger screens.

plurals
  1. POkendo drop down return object object
    primarykey
    data
    text
    <p>I have a problem with kendo drop-down list.Drop down returns the object object, but i need string. Can somebody help me. Here codes. I'm sorry for my english, i'm from Russia</p> <p>MyScript.js:(get data from Admin controller)</p> <pre><code> $(document).ready(function () { $("#grid").kendoGrid({ dataSource: { type: 'odata', serverSorting: true, serverFiltering: true, serverPaging: true, transport: { read: { url: "/api/Admin", dataType: "json", contentType: "application/json", }, create: { url: "/api/Admin", dataType: "json", type: "POST" }, update: { url: function (AdminModel) { return "/api/Admin/" + "?roles=" + AdminModel.Roles }, dataType: "json", type: "PUT" }, destroy: { url: function (AdminModel) { return "/api/Admin/" + "?name=" + AdminModel.Name }, dataType: "json", type: "DELETE" }, parameterMap: function (model, operation) { if (operation !== "read" &amp;&amp; model) { return kendo.stringify(model); } } }, schema: { data: function (response) { if (response.value !== undefined) return response.value; else { delete response["odata.metadata"]; return response; } }, total: function (response) { return response['odata.count']; }, model: { id: "ID", fields: { ID: { editable: false }, Name: { type: "string", editable: false, nullable: false, validation: { required: true } }, Roles: { type: "string", editable: false }, NewRole: { type: "string" }, } } } }, height: 560, sortable: true, pageable: true, editable: "popup", columns: [ { field: "ID", width: 50 }, { field: "Name", title: "Name", width: 120 }, { field: "Roles", title: "Roles", width: 120}, { field: "NewRole", hidden:true,title: "NewRole", editor: RoleDropDownEditor, template: "#=NewRole#" }, { command: ["destroy", "edit"], title: " ", width: "120px" } ] }); }); My Drop Down List(get data from Role controller) function RoleDropDownEditor(container, options) { $('&lt;input required data-bind="value:' + options.field + '"/&gt;') .appendTo(container) .kendoDropDownList({ dataTextField: "Role", dataValueGield: "Id", autoBind: false, dataSource: { transport: { read: { url: "/api/Role", dataType: "json", contentType: "application/json", }, schema: { model: { fields: { Id:{type:"string"}, Role: { type: "string" } } } } } } }); } </code></pre> <p><strong>Controller</strong></p> <pre><code>Web API class Role.cs using MyCMS.Models; using System.Web.Security; namespace MyCMS.Controllers { public class RoleController : ApiController { private UsersContext db = new UsersContext(); public class MyRole { public string Id { get; set; } public string Role { get; set; } } // GET api/usermanage public List&lt;MyRole&gt; Get() { var result = new List&lt;MyRole&gt;(); foreach (var role in Roles.GetAllRoles()) { result.Add(new MyRole{ Id = role, Role = role}); } return result; } } } </code></pre> <p><strong>View</strong></p> <pre><code> &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;div id="grid"&gt;&lt;/div&gt; @section Scripts{ @Styles.Render("~/Content/kendo/2013.2.716/css") @Scripts.Render("~/bundles/kendo") @Scripts.Render("~/bundles/Admin") } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload