0

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

我的标记:

<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,
});
4

2 回答 2

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
                            }
                    }
        },
于 2012-11-26T18:04:08.887 回答
1

您应该使用数据源的同步事件。

var goalsDataSource = new kendo.data.DataSource({
    sync: function(e){
        alert('Synchronization has completed! Your changes are saved!')
    }
//...
于 2012-11-26T19:19:15.893 回答