I would like to add data to a kendoGrid from a form, not a grid toolbar.
I'm able to add data to the grid with the add() method but when I call sync() on dataSource, create: it never gets called.
This example code it's close to my original code statement even if - in fact - I'm using remote data binding. Anyway, it gives me the same results
HTML:
JS:
I'm doing something wrong? Any ideas?
I'm able to add data to the grid with the add() method but when I call sync() on dataSource, create: it never gets called.
This example code it's close to my original code statement even if - in fact - I'm using remote data binding. Anyway, it gives me the same results
HTML:
<div class="k-toolbar"><input type="text" id="inputColor"></input><button id="addColorButton">Add Color</button></div><div id="grid"></div>JS:
var colors = [{ "ID": 1, "Name": "Blue"}, { "ID": 2, "Name": "Red" }]; var dataModel = new kendo.data.Model.define({id: "ID"}); var localDataSource = new kendo.data.DataSource({ transport:{ read: function(options){ options.success(colors); }, create: function(){ alert('Creating...'); } }, schema: { model: dataModel } }); $('#grid').kendoGrid({ dataSource: localDataSource, columns: [{title:"Color", field:"Name"}] }); $('#addColorButton').bind("click", function(){ localDataSource.add({ Name: $('#inputColor').val() }); localDataSource.sync(); });I'm doing something wrong? Any ideas?