如何在基于Id的kenod网格中绑定kendo组合

时间:2016-09-28 17:12:35

标签: jquery kendo-ui kendo-grid

我在kendo网格中绑定了kendo combo。组合应基于相邻列的项代码动态绑定。我写了下面的代码。组合不会绑定。

$("#DieItemGrid").kendoGrid({
                    dataSource: {
                        data: result,
                        autoSync: true,
                        schema: {
                            model: {
                                id: 'ParentItemId',
                                fields: {
                                    ParentItemCd: { type: "string", nullable: false },
                                    ChildItemCd: { editable: false }
                                }
                            }
                        }
                    },
                    columns:
                        [
                        {
                            field: "ChildItemCd",
                            title: "Die Item Code",
                            headerAttributes: {
                                style: "vertical-align: middle;"
                            }

                        },
                         {
                             field: "InternalRevDatalist", title: parentItemCd + "<br>Int. Rev Step",
                             editor:
                              function (container, options) {
                                  $.FwAJAX({
                                      showBusyIndicator: false,
                                      url: $.FwRoute.Base() + "GetInternalRevStepList",
                                      data: { itemCd: "#=ChildItemCd#" },//not able to get this id
                                      //data: {itemCd: '10036064'},
                                      dataType: 'json',
                                      success: function (result) {
                                          $('<input required name="' + options.field + '"/>')
                                              .appendTo(container)
                                              .kendoComboBox({
                                                  autoBind: false,
                                                  dataTextField: "Description",
                                                  dataValueField: "FriendlyId",
                                                  placeholder: "-- Select --",
                                                  dataSource: result,
                                                  change: function (e) {
                                                      e.preventDefault();
                                                    //onchange
                                                  }
                                              });
                                      }
                                  });


                              }
                             , template: dieinternalRevListTemplate

                         }
                        ],

                    dataBound: function () {
                        var dataView = this.dataSource.view();
                        for (var i = 0; i < dataView.length; i++) {
                            var uid = dataView[i].uid;
                            $("#DieItemGrid tbody").find("tr[data-uid=" + uid + "]").addClass("datadisable");
                        }
                    },
                    editable: true,
                    selectable: "multiple cell",
                });

enter image description here

我无法获得ChildItemCd。根据这个ID,我需要填充组合框。

1 个答案:

答案 0 :(得分:1)

options参数中,您有一个名为model的属性,它是当前行的模型。

使用它像:

data: { itemCd: options.model.ChildItemCd }

Demo