Search code examples
javascriptkendo-ui-gridkendo-ui-mvc

Inline Grid kendoComboBox get value in javascript


This is my function 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"
            //}
          },
        },
      }),
    })
}

I want to catch kendoComboBox value go controller and come back with user name contains value just give me way to take value PLEASE!!!!

This is my grid column area

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']));

Solution

  • Hy guys this is my answer.I hope this answer help you.And teleric people Alex give me that link maybe can help 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 })
            //    }
            //});
    };