This is a migrated thread and some comments may be shown as answers.

Kendo Grid Editor not Binding/Registering with DataSource

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stan
Top achievements
Rank 1
Stan asked on 19 Aug 2014, 10:55 PM
Here is a simplified version of my code (there is nothing in the <table>):

var _manu = [{"text":"Acme","value":1},{"text":"Other","value":2}];
 
function getManufacturerName(id) {
        for (var i = 0; i < _manu.length; i++) {
            if (_manu[i].value == id) { return _manu[i].text; }
        }
        return '';
    }
 
gridDataSource = new kendo.data.DataSource({
                batch: true,
                transport: {
                    read: { url: 'myUrl' },
                },
                schema: {
                    model: {
                        id:"ItemId",
                        fields: {
                            ManuId: { type: "number" }
                        }
                    }
                }
           });
 
var kendoGrid = gridObj.kendoGrid({
                dataSource: gridDataSource,
                selectable: "row",
                editable: true,
                columns: [
                    {
                        field: "ManuId",
                        title: "Manufacturer",
                        editor: manufacturerDropDownEditor,
                        template:"#= getManufacturerName(ManufacturerId) #"
                    }
                ]
            }).data('kendoGrid');
 
 
function manufacturerDropDownEditor(container, options) {
            $('<input data-bind="value:' + options.field + '"/>')
                .appendTo(container)
                .kendoDropDownList({
                    dataTextField: "text",
                    dataValueField: "value",
                    dataSource: _manu
                });
        }

And everything works fine, except that when I use the dropdown to change the value, it never changes in the datasource.  My change even never fired (I cut it out of here) and if I try to update, the field edited by the dropdown is not changed.  THe other fields (there are text fields, number fields, etc. in the none abbreviated code) all fire the change event and show up in the datasource.  Any idea why this isn't changing anything?

1 Answer, 1 is accepted

Sort by
0
Stan
Top achievements
Rank 1
answered on 20 Aug 2014, 02:39 PM
Turns out that a "number" field cannot handle 'null', so make sure you send any 'null' values a different value like -1 or 0 - other wise KendoGrid with and Editor will appear to work, but not actually do anything (a console message would be nice).
Tags
Grid
Asked by
Stan
Top achievements
Rank 1
Answers by
Stan
Top achievements
Rank 1
Share this question
or