【问题标题】:My extjs grid is not showing in new archictecture我的 extjs 网格未在新架构中显示
【发布时间】:2011-03-18 20:50:58
【问题描述】:

我正在使用我的 extjs 应用程序的架构来自这篇博文 http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/ 所以这是我的 index.html 请阅读整个问题以获得完整答案。

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Reseller DashBoard</title>

    <!-- ** CSS ** -->
    <!-- base library -->
    <link rel="stylesheet" type="text/css" href="./ext/resources/css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="./ext/resources/css/xtheme-gray.css" />

    <!-- overrides to base library -->

    <!-- ** Javascript ** -->
    <!-- ExtJS library: base/adapter -->
    <script type="text/javascript" src="./ext/adapter/ext/ext-base-debug.js"></script>

    <!-- ExtJS library: all widgets -->
    <script type="text/javascript" src="./ext/ext-all-debug.js"></script>

    <!-- overrides to base library -->

    <!-- page specific -->
    <script type="text/javascript" src="application.js"></script>
    <script type="text/javascript" src="js/Application.dashboard.js"></script>
    <script type="text/javascript" src="js/jsfunction.js"></script>
    <script type="text/javascript" src="js/reseller.js"></script>


</head>
<body>

    <div id="dashboard">
    </div>
</body>
</html>

这是我的 application.js 我在这里初始化我的仪表板网格,它是初始化的正确位置吗?

/*global Ext, Application */

Ext.BLANK_IMAGE_URL = './ext/resources/images/default/s.gif';
Ext.ns('Application');

// application main entry point
Ext.onReady(function() {

    Ext.QuickTips.init();
    var pg = new Application.DashBoardGrid();

    // or using it's xtype
    var win = new Ext.Window({
         items:{xtype:'DashBoardGrid'}
    });

    // code here

}); // eo function onReady

// eof

这是我的 Application.DashBoardGrid.js 我对 api 的请求现在要执行两次为什么? 我有一个用于渲染列的linkrenderer 函数,我应该把这个函数放在哪里? 并提出为什么我的网格没有出现?

Application.DashBoardGrid = Ext.extend(Ext.grid.GridPanel, {
     border:false
    ,initComponent:function() {
        var config = {
            store:new Ext.data.JsonStore({
                // store configs
                autoDestroy: true,
                autoLoad :true,
                url: 'api/index.php?_command=getresellerscount',
                storeId: 'getresellerscount',
                // reader configs
                root: 'cityarray',
                idProperty: 'cityname',
                fields: [
                    {name: 'cityname'},
                    {name: 'totfollowup'},
                    {name: 'totcallback'},
                    {name: 'totnotintrested'},
                    {name: 'totdealsclosed'},
                    {name: 'totcallsreceived'},
                    {name: 'totcallsentered'},
                    {name: 'totresellerregistered'},
                    {name: 'countiro'},
                    {name: 'irotransferred'},
                    {name: 'irodeferred'}
                ]
            })
            ,columns: [
                {
                    id       :'cityname',
                    header   : 'City Name', 
                    width    : 120, 
                    sortable : true, 
                    dataIndex: 'cityname'
                },
                {
                    id       :'countiro',
                    header   : ' Total Prospect', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'countiro'
                },
                 {
                    id       :'irotransferred',
                    header   : 'Calls Transfered By IRO', 
                    height : 50,
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'irotransferred'
                },
                {
                    id       :'irodeferred',
                    header   : ' Calls Deferred By IRO', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'irodeferred'
                },
                {
                    id       :'totcallsentered',
                    header   : ' Total Calls Entered', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex : 'totcallsentered'//,
                    //renderer : linkRenderer
                },
                {
                    id       :'totfollowup',
                    header   : ' Follow Up', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totfollowup'
                },
                {
                    id       :'totcallback',
                    header   : ' Call Backs', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totcallback'
                },
                {
                    id       :'totnotintrested',
                    header   : ' Not Interested', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totnotintrested'
                },
                {
                    id       :'totdealsclosed',
                    header   : ' Deals Closed', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totdealsclosed'
                },
                 {
                    id       :'totresellerregistered',
                    header   : ' Reseller Registered', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totresellerregistered'
                }
            ]
          ,plugins:[]
          ,viewConfig:{forceFit:true}
          ,tbar:[]
          ,bbar:[]
          ,render:'dashboard'
          ,height: 350
          ,width: 1060
           ,title: 'Reseller Dashboard'
        }; // eo config object

        // apply config
        Ext.apply(this, Ext.apply(this.initialConfig, config));

        Application.DashBoardGrid.superclass.initComponent.apply(this, arguments);
    } // eo function initComponent

    ,onRender:function() {
        // this.store.load();

        Application.DashBoardGrid.superclass.onRender.apply(this, arguments);
    } // eo function onRender
});

Ext.reg('DashBoardGrid', Application.DashBoardGrid);

Json 响应

{
    "countothercities": "0",
    "directreseller": "14",
    "totalresellersregisteredfor8cities": 33,
    "cityarray": [{
        "cityname": "bangalore",
        "totfollowup": "3",
        "totcallback": "4",
        "totnotintrested": "2",
        "totdealsclosed": "0",
        "totcallsreceived": "0",
        "totcallsentered": "68",
        "totresellerregistered": "6",
        "countiro": "109",
        "irotransferred": "83",
        "irodeferred": "26"
    }]
}

【问题讨论】:

  • 在回答之前等待看到我的评论,现在我的网格正在显示,我没有执行 win.show() 并且我给出了渲染:仪表板?那么现在的问题是把`linkrenderer`函数放在哪里?
  • 好的,我得到了链接渲染函数的放置位置,我正在放置 DashBoardGrid 类并通过此操作符访问

标签: oop architecture extjs grid


【解决方案1】:

请显示您的 JSON 响应或服务器代码。以便我们更好地回答。

我对 api 的请求现在执行了两次为什么?

很明显。 Ext.onReady() 内部
您正在创建 DashboardGrid 的实例。呼叫 1
您要求 Ext 通过传递 xtype 创建 DashboardGrid 的实例。呼叫 2

【讨论】:

  • 在回答之前等待看到我的评论,现在我的网格正在显示,我没有执行 win.show() 并且我给出了渲染:仪表板?那么现在的问题是把`linkrenderer`函数放在哪里?
  • 好的,我得到了链接渲染函数的放置位置,我正在放置 DashBoardGrid 类并通过此操作符访问
  • 是您的 Q 得到了答案,还是仍有问题?
  • 现在我有这个问题,请检查stackoverflow.com/questions/5350236/…
【解决方案2】:

您正在创建两次网格。改为这样做。

Ext.onReady(function() {
    Ext.QuickTips.init();

    var win = new Ext.Window({
         items:{xtype:'DashBoardGrid'}
    });

    // code here

}); // eo function onReady

【讨论】:

猜你喜欢
  • 2012-08-22
  • 2012-12-28
  • 2012-05-05
  • 2012-06-20
  • 1970-01-01
  • 1970-01-01
  • 2017-01-12
  • 1970-01-01
  • 2013-07-25
相关资源
最近更新 更多