使用KendoGrid如何在进行批量编辑时弹出“成功保存”消息?

时间:2012-11-26 17:08:51

标签: javascript telerik grid kendo-ui

我正在使用KendoUI Grid进行批量编辑。我想在成功保存更改后向用户显示一条消息。我该怎么做?

我的Mark-UP:

<div id="employeeGoalsGrid"></div>

我的Javascript:

var goalsDataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: '/MVC/ResearcherPoints/GetEmployeeResearchers',
            type: 'POST',
            contentType: 'application/json'
        },
        update: {
            url: '/MVC/ResearcherPoints/UpdateEmployeeGoal',
            type: 'POST',
            contentType: 'application/json'
            //dataType: "jsonp"
        },
        parameterMap: function (options, type) {
            debugger;
            $.extend(options, { ID: options.id });
            return JSON.stringify(options);
        }
    },
    batch: false,
    schema: {
        model: {
            id: 'ID',
            fields: {
                id: { editable: false, nullable: false },
                FirstName: { editable: false, nullable: true  },
                LastName: { editable: false, nullable: true },
                Title: { editable: false, nullable: true },
                TeamName: { editable: false, nullable: true },
                PointsGoal: { type: "number", nullable: true, validation: { required: false, min: 1 } }
            }
        }
    },
    sortable: true,
    filterable: true,
    columnMenu: true
});


$('#employeeGoalsGrid').kendoGrid({
    dataSource: goalsDataSource,
    navigatable: true,
    sortable: true,
    resizable: true,
    toolbar: ["save", "cancel"],
    columns: [
        { field: "FirstName", title: "First Name", width: 200},
        { field: "LastName", title: "Last Name", width: 200 },
        { field: "Title", title: "Title", width: 200 },
        { field: "TeamName", title: "Team", width: 200 },
        { field: "PointsGoal", title: "Goal", width: 200 }],
    editable: true,
    filterable: true,
});

2 个答案:

答案 0 :(得分:2)

罗德尼,如何利用完整的赛事。它有点脏,我同意,但我从未设法使剑道成功事件工作(不确定是否有人曾设法 - 剑道?)。

 update: {
            url: '/MVC/ResearcherPoints/UpdateEmployeeGoal',
            type: 'POST',
            contentType: 'application/json',
            complete: function (jqXhr, textStatus) {
                            if (textStatus == 'success') {
                                var result = jQuery.parseJSON(jqXhr.responseText);
                                // read your result   
                                // open your dialog
                            }
                    }
        },

答案 1 :(得分:1)

您应该使用dataSource的sync事件。

var goalsDataSource = new kendo.data.DataSource({
    sync: function(e){
        alert('Synchronization has completed! Your changes are saved!')
    }
//...