1

我创建了一个 KendoUI 网格,其中第一列使用自定义编辑器。编辑后不会调用更新请求,但如果不使用编辑器会调用更新请求。为什么?

var columns = [
    { field: 'AccountId', title: '客户名称', locked: false, template: '#= me.detail.brandName(data, \'ID\') #', editor: accountGridEditor, width: 200 },
    { field: 'BankNo', title: '付款银行', template: '#= me.detail.format(data, \'Bank\') #', attributes: { style: 'text-align: left;' }, width: 150 },                            
    { field: 'UnLinkedAmount', title: '未分配', template: '#= me.detail.format(data, \'UnLinkedAmount\') #', attributes: { style: 'text-align: left;' }, width: 100 },
    { command: ["edit", "destroy"], title: " ", width: "250px" }
    ];


var dataSource = c.dataSourceOption({
    transport: {
    read: { url: url.api('Finance/FundJournal') },
    update: { url: url.api('Finance/FundJournal', { action: 'post' }) },
    destroy: { url: url.api('Finance/FundJournal', { action: 'delete' }), type: 'delete' },
    parameterMap: function (data, type) {
        console.log(type);
        console.log(data);
        if (type === 'read') return getReadParameters();
        if (type === "update") return data;
        if (type === 'create') return data;
        if (type === 'destroy') return { id: data.Id };
        return data;
    }
},
schema: {
    model: {
        id: "Id",
        fields: {
        AccountId: { editable: true, nullable: false, validation: { required: true } },
        BankNo: { editable: false},
        UnLinkedAmount: { editable: false }
    }
                            }
},
filter: [{ field: 'SubType', operator: 'neq', value: 'Id' }]

});

    var grid = $("#result").kendoGrid({
    dataSource: dataSource,
    height: 550,
    columns: columns,
    editable: "inline",
    save:function(e){$.ajax();}
}).data('kendoGrid');
4

1 回答 1

0

如果从下拉列表中设置记录属性,如下所示:

change: function() {
    options.model.Name = this.value();
    options.model.dirty = true;
}

有必要将该模型显式设置为脏模型,以告知数据源该记录已被修改并需要更新。否则,您可以使用set().

change: function() {
    options.model.set('Name',this.value());
}

这样记录会在数据源中自动标记为脏。

于 2016-05-28T15:47:45.390 回答