Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kendo ui 带有模型添加项的剑道UI数据源_Kendo Ui - Fatal编程技术网

Kendo ui 带有模型添加项的剑道UI数据源

Kendo ui 带有模型添加项的剑道UI数据源,kendo-ui,Kendo Ui,我使用datasource从azure移动服务(因为datasource与其他剑道控件配合得很好)中获取定义了模式的数据。但是,当我尝试在数据源中添加项或在InvoiceModel中推送项(selectedItem.Items)时,视图中显示2,即使项的数组长度为1,hear也是我的代码(不尝试同步数据源) 数据源: var invoiceItemsDataSource = new kendo.data.DataSource({ transport: {

我使用datasource从azure移动服务(因为datasource与其他剑道控件配合得很好)中获取定义了模式的数据。但是,当我尝试在数据源中添加项或在InvoiceModel中推送项(selectedItem.Items)时,视图中显示2,即使项的数组长度为1,hear也是我的代码(不尝试同步数据源)

数据源:

var invoiceItemsDataSource = new kendo.data.DataSource({        
        transport: {
            tbl: azureService.client.getTable('SCCustomerInvoiceItem'),
            read: function (options) {
                this.tbl.where({ SCCustomerInvoiceHeaderID: options.data.filter.filters[0].value }).read().done(
                    function (d) {
                        options.success(d);
                    }, function (err) {
                        options.error(err);
                    });
            },
            update: function (options) {
                delete options.data.TStamp;
                this.tbl.update(options.data).done(function (d) {
                    options.success(d);
                }, function (err) {
                    options.error(err);
                });
                options.cache = false;
            },
            create: function (options) {
                options.data.isNew();
                this.tbl.insert(options.data).done(function (d) {
                    options.success(d);
                }, function (err) {
                    options.error(err);
                });
                options.cache = false;
            },
        },
        serverFiltering: true,
        schema: {
            model: invoiceItemModel,

        }
    });
型号:

var invoiceModel = kendo.data.Model.define({
        id: "id",
        fields: {
            CustomerInvoiceNo: { type: "string" },
            CustomerID: { type: "number" },
            OrganisationNameEn: { type: "string" },
            TotalAmount: { type: "number" },
            StatusID: { type: "number" },
        },
        Items: [],
        Customer: {},
        InvoiceWithCustomer: function () {
            return 0;
        },
        TotalAmountCalc: function () {
            var sum = 0;
            return kendo.parseFloat(sum).toFixed(2);
        }
    });
var invoiceItemModel = kendo.data.Model.define({
        id: "id",
        fields: {
            ProductID: { type: "number" },
            Quantity: { type: "number" },
            PricePerUnit: { type: "number" }
        },
        SumItemAmount: function () {
            var data = 0;
            data = this.get("PricePerUnit") * this.get("Quantity");
            return data.toFixed(2);
        }});
可观察到:

var extendModule = {
        selectedItem: new invoiceModel(),//this is also a model that has a property Items[]
        workingInvoiceItem: new itemModel(),
        saveItem: function () {
            var elData = this.workingInvoiceItem;
            this.selectedItem.Items.push(elData);
            this.hideDialog();
        },
        hideDialog: function () {
            $('#invoiceItemDialog').data('kendoWindow').close();
        }
    };
    var model = kendo.observable(extendModule);
那景色呢

<table>
                    <thead>
                        <tr>
                            <th>Item</th>
                            <th>Quantity</th>
                            <th>Price</th>
                        </tr>
                    </thead>
                    <tbody data-bind="source: selectedItem.Items" data-template="invoiceItemTable-Template">                    </tbody>
                </table>

项目
量
价格