0
votes

I'm showing my class A in a Kendo grid with ajax data source. This class has a foreign key relationship with class B and a navigation property for that class. I'd like to show class B properties in separate textboxes. What's the best way to achieve this? I think I should be using dataBound event somehow?

1

1 Answers

0
votes

Just for the record, and to prevent another badge like Tumbleweed!, I should say the only way I came up with was custom Ajax.

  1. You should extract current row's ID.
  2. Make an Ajax call and update required fields.

You can register a handler for Grid's change with this JS code:

$(document).ready(function () {
    $("#grid").data("kendoGrid").bind("change", headChange);
    $("#grid").data("kendoGrid").bind("dataBound", function (e) {
        this.element.find("tbody tr:first").addClass("k-state-selected");
        headChange(e);
    });
});

And the Ajax call will be something like this:

function headChange(e) {
    var grid = $("#grid").data("kendoGrid");
    var item = grid.dataItem(grid.select());
    var data = item.Id;
    $.ajax({
        method: "POST",
        url: "url/details" + id,
        success: function (data) {
            var lbl = $("#lbl1").val(data[0].lbl1);
        }
    });
}