簡體   English   中英

ExtJS4網格存儲/模型顯示空行

[英]ExtJS4 Grid store/model showing empty row(s)

我的問題與這個問題非常相似:

ExtJS4 gridPanel數據未顯示

但是在語法和行為上有些許差異,我花了很多天的時間通過多種方式嘗試解決,但是失敗了。

請注意 :我必須通過調用父構造函數而不是json字段構造來保持SharpKit.NET生成行為,例如下面的代碼

Ext.define("Core.Scripts.model.Book", {
    extend: "Ext.data.Model",
    fields: ["title", "pages"] // Do not use this
});

Ext.define("Core.Scripts.model.Book", {
    extend: "Ext.data.Model",
    constructor: function () {
        this.callParent([{ fields: ["title", "pages"] }]); // Use this
    }
});

這是我在jsfiddle http://jsfiddle.net/thanhptr/LqXan/上的簡化版本的鏈接。 貝婁是我復制的代碼,此代碼仍無法解決:

Ext.define("Core.Scripts.model.Book", {
    extend: "Ext.data.Model",
    constructor: function () {
        this.callParent([{ fields: ["title", "pages"] }]);
    }
});
Ext.define("Core.Scripts.store.Store", {
    extend: "Ext.data.Store",
    constructor: function () {
        this.callParent([{
            model: "Core.Scripts.model.Book",
            data: [
                { title: "book 1", pages: 10 },
                { title: "book 2", pages: 20 }
            ]
        }]);
    }
});
Ext.define("Core.Scripts.view.GridPanel", {
    extend: "Ext.grid.Panel",
    constructor: function () {
        this.callParent([{
            store: new Core.Scripts.store.Store(),
            region: "center",
            columns: [
                { header: "title", dataIndex: "title" },
                { header: "pages", dataIndex: "pages" }
            ]
        }]);
    }
});
Ext.define("Core.Scripts.view.DetailViewport", {
    extend: "Ext.container.Viewport",
    constructor: function () {
        this.callParent([{
            frame: true,
            layout: "border",
            items: [new Core.Scripts.view.GridPanel()]
        }]);
    }
});
Ext.onReady(function () {
    var viewPort = new Core.Scripts.view.DetailViewport();
});

我也無法使您的示例正常工作,但是我更改了一些代碼並使它正常工作。

Ext.define("Core.Scripts.model.Book", {
    extend: "Ext.data.Model",
    fields: ["title", "pages"]
});
Ext.define("Core.Scripts.store.Store", {
    extend: "Ext.data.Store",
    model: "Core.Scripts.model.Book",
    data: [
        { title: "book 1", pages: 10 },
        { title: "book 2", pages: 20 }
    ]
});

Ext.define("Core.Scripts.view.GridPanel", {
    extend: "Ext.grid.Panel",
    region: "center",
    height: '200',
    store: Ext.create('Core.Scripts.store.Store'),
    columns: [
        { header: "title", dataIndex: "title" },
        { header: "pages", dataIndex: "pages" }
    ]

});

Ext.define("Core.Scripts.view.DetailViewport", {
    extend: "Ext.container.Viewport",
    frame: true,
    layout: "border",
    initComponent: function () {
        this.items = [new Core.Scripts.view.GridPanel];
        this.callParent(arguments);     
    }

});
Ext.onReady(function () {
    var viewPort = new Core.Scripts.view.DetailViewport();
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM