Kendo Grid Foreign Key Fields

2 posts, 0 answers
  1. KobusVisagie
    KobusVisagie avatar
    47 posts
    Member since:
    Sep 2010

    Posted 18 Oct 2012 Link to this post

    Hi Everyone

    I want to know if someone can help me out a bit, i am trying to use the foreign key columns, which is working just fine, accept, for some reason my kendo grid shows numeric text boxes instead of comboboxes, and i have followed the examples, but with no luck could i get them right :( attached is the code i am using

                .Columns(c =>
                        c.Bound(e => e.HomologationItemPriceID).ClientTemplate("<input id='#=ItemPriceID#' type='checkbox'/>").Template(t => "<input id='" + t.ItemPriceID + "' type='checkbox'/>").Title("").Width(30);
                        c.Bound(e => e.ItemPriceID).Filterable(false).Visible(false);
                        c.Bound(e => e.Item);
                        c.Bound(e => e.ItemPrice).Width(120);
                        c.ForeignKey(e => e.PriorityID, (System.Collections.IEnumerable)ViewData["priorities"], "id", "datatext").Title("Priority").Width(170);
                        c.ForeignKey(e => e.StatusID, (System.Collections.IEnumerable)ViewData["statuses"], "id", "datatext").Title("Status").Width(170);
                .Editable(e => e.Mode(GridEditMode.InCell))
                .Selectable(e => e.Mode(GridSelectionMode.Multiple))
                .DataSource(e =>
                    .Events(g => g.Error("ItemGridError"))
                    .Model(m =>
                        m.Field(f => f.ItemPrice).Editable(false);
                        m.Field(f => f.Item).Editable(false);
                        m.Id(i => i.HomologationItemPriceID);
                    .Read(r =>
                            r.Action("GetItems", "StockInspection");

    ViewData gets populated like this, the ModuleViewListDTO string(for values) and long(for ID's) properties
    ViewData["priorities"] = _priorities = JsonConvert.DeserializeObject<ModuleViewListDTO>(GetOrPost("get", ApiUrl + "/api/Items?lookup=Priority", "")).data;
                    ViewData["statuses"] = _statuses = JsonConvert.DeserializeObject<ModuleViewListDTO>(GetOrPost("get", ApiUrl + "/api/Items?lookup=ItemStatus", "")).data;

    Attached is the results

  2. Rosen
    Rosen avatar
    3247 posts

    Posted 19 Oct 2012 Link to this post

    Hi Gregory,

    Could you please verify that you have added the GridForeignKey editor template file (available with the KendoUI for ASP.NET MVC distribution). You may find additional information about the editor templates here.

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top