PokéDev
PokéDev

Reputation: 163

KendoUI - Cancel button deletes rows

JSFiddle: http://jsfiddle.net/bhoff/ZCyPx/63/

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({
        interval: 15
    });
}

function dateTimeEditor(container, options) {
    console.log("options", options);
    $('<input data-text-field="' + options.field + '" data-value-field="' + options.field + '" data-bind="value:' + options.field + '" data-format="' + options.format + '"/>')
        .appendTo(container)
        .kendoDateTimePicker({});
}



$("#grid").kendoGrid({
    dataSource: {
        data: entries,
        schema: {
            parse: function (response) {
                $.each(response, function (idx, elem) {
                    if (elem.time && typeof elem.time === "string") {
                        elem.time = kendo.parseDate(elem.time, "HH:mm:ss");
                    }
                    if (elem.datetime && typeof elem.datetime === "string") {
                        elem.datetime = kendo.parseDate(elem.datetime, "HH:mm:ss");
                    }
                });
                return response;
            },
            model : {
                fields : {
                    type : { editable: false } 
                }
            }
        }
    },

Whenever I select my cancel button (after selecting edit) it always deletes the entire row (on Chrome and Firefox), is there a part of the grid that I am not coding correctly or could this be a version issue?

Any assistance would be greatly appreciated, thanks!

Upvotes: 1

Views: 327

Answers (1)

OnaBai
OnaBai

Reputation: 40887

That happens because you did not declare id field. Assuming that in your grid the field acting as id is type you should define in you model something like:

        model : {
            id:  "type",
            fields : {
                type : { editable: false } 
            }
        }

Here the JSFiddle modified http://jsfiddle.net/OnaBai/ZCyPx/64/

Upvotes: 1

Related Questions