这是我的函数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 值去 Controller ,并返回包含值的用户名,请给我取值的方法!!!!
这是我的网格列区域
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']));

最佳答案

大家好,这是我的答案。希望这个答案对您有所帮助。Alex的电话专家告诉我,该链接可能会对您有所帮助

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 })
        //    }
        //});
};

关于javascript - 内联网格kendoComboBox在javascript中获得值(value),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63488025/

10-13 00:38