内联网格 kendoComboBox 在 javascript 中获取值

Inline Grid kendoComboBox get value in javascript

这是我的函数userNameEditor

function userNameEditor(container, options) {
  $('<input required data-bind="value:' + options.field + '"/>')
    .appendTo(container)
    .kendoComboBox({
      dataTextField: "UserName",
      dataValueField: "UserId",
      filter: "contains",
      minLength: 3,
      //_readMethod: '../Warehouse/SearchUser',
      dataSource: new kendo.data.DataSource({
        transport: {
          contentType: "application/json; charset=utf-8",
          serverFiltering: true,
          read: {
            url: "../Warehouse/SearchUser",
            //data: { //?????????//
            //    q: function () {
            //        return $("#autoComplete").data("kendoAutoComplete").value();
            //    },
            //    maxRows: 10,
            //    username: "demo"
            //}
          },
        },
      }),
    })
}

我想抓住 kendoComboBox 值去控制器并返回包含值的用户名请给我获取值的方法!!!!

这是我的网格栏区域

grid._columns.push(grid.GridColumn('Id', null, '200px', null, null, null, null, null, null, null, true));
grid._columns.push(grid.GridColumn('User', 'User', '200px', null, "#=User.UserName#", null, null, null, null, null, null, null, null, null, userNameEditor));
grid._columns.push(grid.GridColumn(null, ' ', '200px', { style: 'text-align:right' }, null, null, null, null, null, null, null, null, null, ['edit', 'destroy']));

大家好,这是我的 answer.I 希望这个答案能帮助 you.And telerik 人 Alex 给我 link 也许可以帮助 https://dojo.telerik.com/@bubblemaster/IYekeYoc

function userNameEditor(container, options) {
    debugger;
    var gridDataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: '../Warehouse/SearchUser',
                dataType: "json"
            },
            success: function(e) {
                debugger;
            },
            error: function (e) {
                debugger;
            }
        }
    });
        var cmb=$('<input name="' + options.field + '"/>')
        .appendTo(container)
        .kendoComboBox({
            autoBind: false,
            dataTextField: "UserFullName",
            dataValueField: "Id",
            filter: "contains",
            minLength: 3,
            dataSource: gridDataSource,
            filtering: function (e) {
               
                var filter = e.filter;
                gridDataSource.read({ userSearchText: filter.value });
                //dataSource.filter({ userSearchText: filter.value });
            },
            dataBound: function (e) {
                debugger;
                var equipmentData = e.sender.dataSource.data();


                        $.each(equipmentData, function (index, selectedEquipmentData) {
                                var dataItem = e.sender.dataSource.at(index);

                        });
            },
            select: function(e) {
                debugger;
                this.refresh();
            },
            complete: function(e) {
                debugger;
            },
            error: function(e) {
                debugger;
            }
        }).data('kendoComboBox');
    cmb.refresh();
    debugger;
        //.kendoComboBox({
        //    autoBind: false,
        //    dataTextField: "NameSurname",
        //    dataValueField: "Id",
        //    filter: "contains",
        //    minLength: 3,
        //    dataSource: dataSource,
        //    filtering: function (e) {
        //        debugger;
        //        var filter = e.filter;
        //        //dataSource.read({ userSearchText: filter.value });
        //        dataSource.filter({ userSearchText: filter.value })
        //    }
        //});
};