我对 kendouis 的列表视图有疑问,如果我编辑一行,则另一行将从附加的数据源中删除。当我编辑第一行时这很好用,但是当我编辑另一行时,第一行被删除。
我注意到在编辑第一行列表视图的编辑函数时首先调用但是当我编辑第二行数据绑定时,数据绑定然后编辑被调用。
这是代码:
var dataSource = new kendo.data.DataSource({
transport: {
read: function (options) {
options.success(lst);
},
update: function (options) {
oThis.httpService.Post('api/DynamicPricing/UpdateDynamicItem', lst)
.success(function (data, status) {
options.success(data);
});
},
schema: {
model: {
id: "Id",
fields: {
Name: { type: "string" },
CategoryF: { type: "string" },
DirectCost: { type: "number" },
IndirectCost: { type: "number" },
StrategyType: { type: "string" },
Value: { type: "string" },
OverridePrice: { type: "number" },
Current: { type: "string" }
}
}
}
});
list = $('#listcontent').kendoListView({
template: kendo.template('<table cellpadding="3px" class="gridDynamicPricingContent"><tr> \
<td width="100px">#:Name#</td> \
<td width="100px">#:CategoryF#</td> \
<td width="100px" align="right">#:DirectCostF#</td> \
<td width="100px" align="right">#:IndirectCostF#</td> \
<td width="100px">#:StrategyType#</td> \
<td width="50px">#:Value#</td> \
<td width="100px" style="text-align:right; padding-right:5px;" >#:OverridePriceF#</td> \
<td width="100px">#:Current#</td > \
<td width="100px"><a class="k-button k-edit-button" href = "\\#"><span class="k-icon k-edit"></span></a></td>\
</tr></table>'),
editTemplate: kendo.template('<table class="gridDynamicPricingContent k-state-selected"><tr> \
<td width="100px">#:Name#</td> \
<td width="100px">#:CategoryF#</td> \
<td width="100px" align="right">#if(DynamicPricingType==5){# #:data.DirectCost# #}else{#<input type="number" style="width:60px;" class="k-textbox" data-bind="value:DirectCost" name="DirectCost" />#}#</td> \
<td width="100px" align="right">#:IndirectCost#</td> \
<td width="100px">#:StrategyType#</td> \
<td width="50px">#:Value#</td> \
<td width="100px" style="text-align:right; padding-right:5px;">#if(DynamicPricingType==4 || DynamicPricingType==5){#<input type="number" class="k-textbox" style="width:60px;" data-bind="value:OverridePrice" name="OverridePrice" />#}else{# #:data.OverridePrice# #}#</td> \
<td width="100px">#:Current#</td > \
<td width="100px"><a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-update"></span></a></td> \
</tr></table>'),
dataSource: dataSource,
selectable: true,
dataBound: function () {
$('#listcontent').prepend(header);
}
});//.data("kendoListView");