kendo ui - Why does the KendoUI Grid Transport Create event gets raised multiple times, and even when the action is Update? -


i have put fiddle demonstrates in kendoui 2013.1.319, when editing record in grid , press update button on edit dialogue, raises transport create event, instead of update event, , raises once each record.

open following fiddle , press edit button on first record in grid, , press update button on edit dialogue, , have in console window , see have logged event raised , record id passed event.

http://jsfiddle.net/codeowl/fakdc/

why happening, , how fix it?

regards,

scott

code keep stackoverflow happy:

<div id="testgrid"></div>  var _data = [{ "sl_testdata_id": "1", "sl_testdata_number": "1", "sl_testdata_string": "test", "sl_testdata_date": "1971-12-19", "sl_testdata_datetime": "1971-12-19 12:00:00", "sl_testdata_time": "00:30:00", "sl_testdata_boolean": "1" }, { "sl_testdata_id": "2", "sl_testdata_number": "22", "sl_testdata_string": "test 2", "sl_testdata_date": "2013-05-01", "sl_testdata_datetime": "2013-05-01 03:05:22", "sl_testdata_time": null, "sl_testdata_boolean": "1" }, { "sl_testdata_id": "3", "sl_testdata_number": "55", "sl_testdata_string": "test 3", "sl_testdata_date": "2013-05-02", "sl_testdata_datetime": "2013-05-02 05:33:45", "sl_testdata_time": null, "sl_testdata_boolean": "0" }, { "sl_testdata_id": "10", "sl_testdata_number": "1", "sl_testdata_string": "test12", "sl_testdata_date": "1971-12-19", "sl_testdata_datetime": "1971-12-19 12:00:00", "sl_testdata_time": "00:30:00", "sl_testdata_boolean": "1" }];  var _kendodatasource = new kendo.data.datasource({     transport: {         read: function (options) {             console.log('transport read event raised');             options.success(_data);         },         create: function (options) {             console.log('transport create event raised - record id: ' + options.data.sl_testdata_id);             _data.push(options.data);             options.success(options.data);         },         update: function (options) {             console.log('transport update event raised - record id: ' + options.data.sl_testdata_id);             var objrecord = $.grep(_data, function (e) { return e.sl_testdata_id == options.data.sl_testdata_id; });             _data[_data.indexof(objrecord)] = options.data;             options.success(options.data);         },         destroy: function (options) {             console.log('transport destroy event raised');             _data.splice(_data.indexof(options.data), 1);             options.success(options.data);         }     },     serverpaging: true,     serverfiltering: true,     serversorting: true,     sortable: {         mode: 'multiple',         allowunsort: true     },     pageable: {         buttoncount: 5     },     schema: {         model: {             id: "users_id",             fields: {                 sl_testdata_id: { editable: false, nullable: false, defaultvalue: 0 },                 sl_testdata_number: { type: "int", validation: { required: true, defaultvalue: 0 } },                 sl_testdata_string: { type: "string", validation: { required: true } },                 sl_testdata_date: { type: "date", validation: { required: true } },                 sl_testdata_datetime: { type: "date", validation: { required: true } },                 sl_testdata_time: { type: "date", validation: { required: true } },                 sl_testdata_boolean: { type: "bool", validation: { required: true, defaultvalue: false } }             }         }     },     error: function (a) {         $('#testgrid').data("kendogrid").cancelchanges();     } });  function datetimeeditor(container, options) {     $('<input data-text-field="' + options.field + '" data-value-field="' + options.field + '" data-bind="value:' + options.field + '" data-format="' + options.format + '"/>')     .appendto(container)     .kendodatetimepicker({}); }  function timeeditor(container, options) {     $('<input data-text-field="' + options.field + '" data-value-field="' + options.field + '" data-bind="value:' + options.field + '" data-format="' + options.format + '"/>')     .appendto(container)     .kendotimepicker({}); }  // initialize grid $("#testgrid").kendogrid({     columns: [         { field: "sl_testdata_id", title: "id" },         { field: "sl_testdata_number", title: "number" },         { field: "sl_testdata_string", title: "string" },         {             field: "sl_testdata_date",             title: "date",             format: "{0:mm/dd/yyyy}"         },         {             field: "sl_testdata_datetime",             title: "date time",             format: "{0:mm/dd/yyyy hh:mm tt}",             editor: datetimeeditor,             filterable: {                 ui: "datetimepicker"             }         },         {             field: "sl_testdata_time",             title: "time",             format: "{0:hh:mm tt}",             editor: timeeditor,             filterable: {                 ui: "timepicker"             }         },         { field: "sl_testdata_boolean", title: "boolean" },         { command: ["edit", "destroy"], title: "&nbsp;", width: "180px" }     ],     toolbar: ['create'],     editable: 'popup',     sortable: true,     filterable: true,     datasource: _kendodatasource }); 

the problem in model define users_id id there no such field kendo ui undefined means new.

id mandatory whenever have grid editable. kendo ui uses (in combination dirty) know if needs sent server.

if define id sl_testdata_id (not sure if same , it) see sends server data modified or created.

your fiddle modified here http://jsfiddle.net/fakdc/3/


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -