2016-09-05 11 views
2

안녕하세요. extjs를 알기 시작합니다. 나는 내가 풀 수없는 첫 번째 문제를 발견했다. 나는 admin template을 사용한다.Extjs 격자 표 표시

프로젝트 이름/SRC/저장/NavigationTree.js :

Ext.define('Wolf.store.NavigationTree', { 
    extend: 'Ext.data.TreeStore', 

    storeId: 'NavigationTree', 

    fields: [{ 
     name: 'text' 
    }], 

    root: { 
     expanded: true, 
     children: [ 
      { 
       text: 'Dashboard', 
       iconCls: 'x-fa fa-desktop', 
       rowCls: 'nav-tree-badge nav-tree-badge-new', 
       viewType: 'admindashboard', 
       routeId: 'dashboard', // routeId defaults to viewType 
       leaf: true 
      }, 
      { 
       text: 'Email', 
       iconCls: 'x-fa fa-send', 
       rowCls: 'nav-tree-badge nav-tree-badge-hot', 
       viewType: 'email', 
       leaf: true 
      }, 
      { 
       text: 'Profile', 
       iconCls: 'x-fa fa-user', 
       viewType: 'profile', 
       leaf: true 
      }, 
      { 
       text: 'Search results', 
       iconCls: 'x-fa fa-search', 
       viewType: 'searchresults', 
       leaf: true 
      }, 
      { 
       text: 'FAQ', 
       iconCls: 'x-fa fa-question', 
       viewType: 'faq', 
       leaf: true 
      }, 
      { 
       text: 'Pages', 
       iconCls: 'x-fa fa-leanpub', 
       expanded: false, 
       selectable: false, 
       //routeId: 'pages-parent', 
       //id: 'pages-parent', 

       children: [ 
        { 
         text: 'Blank Page', 
         iconCls: 'x-fa fa-file-o', 
         viewType: 'pageblank', 
         leaf: true 
        }, 

        { 
         text: '404 Error', 
         iconCls: 'x-fa fa-exclamation-triangle', 
         viewType: 'page404', 
         leaf: true 
        }, 
        { 
         text: '500 Error', 
         iconCls: 'x-fa fa-times-circle', 
         viewType: 'page500', 
         leaf: true 
        }, 
        { 
         text: 'Lock Screen', 
         iconCls: 'x-fa fa-lock', 
         viewType: 'lockscreen', 
         leaf: true 
        }, 

        { 
         text: 'Login', 
         iconCls: 'x-fa fa-check', 
         viewType: 'login', 
         leaf: true 
        }, 
        { 
         text: 'Register', 
         iconCls: 'x-fa fa-pencil-square-o', 
         viewType: 'register', 
         leaf: true 
        }, 
        { 
         text: 'Password Reset', 
         iconCls: 'x-fa fa-lightbulb-o', 
         viewType: 'passwordreset', 
         leaf: true 
        } 
       ] 
      }, 
      { 
       text: 'Widgets', 
       iconCls: 'x-fa fa-flask', 
       viewType: 'widgets', 
       leaf: true 
      }, 
      { 
       text: 'Forms', 
       iconCls: 'x-fa fa-edit', 
       viewType: 'forms', 
       leaf: true 
      }, 
      { 
       text: 'Charts', 
       iconCls: 'x-fa fa-pie-chart', 
       viewType: 'charts', 
       leaf: true 
      }, 
      { 
       text: 'Views by test1', 
       iconCls: 'x-fa fa-table', 
       viewType: 'testdashboard', 
       leaf: true 
      } 
     ] 
    } 
}); 

프로젝트 이름/SRC /보기/테스트/test.js :

나는 NavigationTree 또 다른 항목을 추가하여 새로운 페이지를 생성
Ext.define('Wolf.view.test.Test', { 
    extend: 'Ext.Container', 
    xtype: 'testdashboard', 

    controller: 'test', 
    viewModel: { 
     type: 'test' 
    }, 

    cls: 'test', 

    scrollable: true, 

    items: [ 
     { 
      xtype: 'bi.testviews', 
      userCls: 'big-100 small-100 dashboard-item shadow' 
     } 
//  { 
//   xtype: 'network', 
// 
//   // 60% width when viewport is big enough, 
//   // 100% when viewport is small 
//   userCls: 'big-60 small-100 dashboard-item shadow' 
//  }, 
//  { 
//   xtype: 'hddusage', 
//   userCls: 'big-20 small-50 dashboard-item shadow' 
//  }, 
//  { 
//   xtype: 'earnings', 
//   userCls: 'big-20 small-50 dashboard-item shadow' 
//  }, 
//  { 
//   xtype: 'sales', 
//   userCls: 'big-20 small-50 dashboard-item shadow' 
//  }, 
//  { 
//   xtype: 'topmovies', 
//   userCls: 'big-20 small-50 dashboard-item shadow' 
//  }, 
//  { 
//   xtype: 'weather', 
//   userCls: 'big-40 small-100 dashboard-item shadow' 
//  }, 
//  { 
//   xtype: 'todo', 
//   height: 340, 
//   userCls: 'big-60 small-100 dashboard-item shadow' 
//  }, 
//  { 
//   xtype: 'services', 
//   height: 340, 
//   userCls: 'big-40 small-100 dashboard-item shadow' 
//  } 
    ] 
}); 

프로젝트 이름/SRC /보기/테스트/TestController.js :

01 23,516,
Ext.define('Wolf.view.test.TestController', { 
    extend: 'Ext.app.ViewController', 
    alias: 'controller.test', 
    requires: [ 
     'Ext.util.TaskRunner' 
    ], 
    onRefreshToggle: function (tool, e, owner) { 

    }, 
    clearChartUpdates: function() { 
    }, 
    destroy: function() { 
    }, 
    onHideView: function() { 
    } 
}); 

프로젝트 이름/SRC /보기/테스트/TestModel.js :

Ext.define('Wolf.view.test.TestModel', { 
    extend: 'Ext.app.ViewModel', 
    alias: 'viewmodel.test', 
    requires: [ 
     'Ext.data.Store', 
     'Ext.data.field.Integer', 
     'Ext.data.field.String', 
     'Ext.data.field.Boolean' 
    ], 
    stores: { 
     hddusage: { 
      autoLoad: true, 
      model: 'Wolf.model.DataXY', 
      proxy: { 
       type: 'api', 
       url: '~api/qg/area' 
      } 

     }, 
     quarterlyGrowth: { 
      autoLoad: true, 
      model: 'Wolf.model.DataXY', 
      proxy: { 
       type: 'api', 
       url: '~api/qg/bar' 
      } 
     }, 
     earnings: { 
      autoLoad: true, 
      model: 'Wolf.model.DataXY', 
      proxy: { 
       type: 'api', 
       url: '~api/qg/line' 
      } 
     }, 
     servicePerformance: { 
      autoLoad: true, 
      model: 'Wolf.model.DataXY', 
      proxy: { 
       type: 'api', 
       url: '~api/qg/pie' 
      } 

     }, 
     topMovies: { 
      autoLoad: true, 
      model: 'Wolf.model.DataXY', 
      proxy: { 
       type: 'api', 
       url: '~api/dashboard/movies' 
      } 
     }, 
     networkData: { 
      autoLoad: true, 
      model: 'Wolf.model.MultiDataXY', 
      proxy: { 
       type: 'api', 
       url: '~api/dashboard/full' 
      } 
     }, 
     visitors: { 
      autoLoad: true, 
      model: 'Wolf.model.MultiDataXY', 
      proxy: { 
       type: 'api', 
       url: '~api/dashboard/visitor' 
      } 
     }, 
     bounces: { 
      autoLoad: true, 
      model: 'Wolf.model.MultiDataXY', 
      proxy: { 
       type: 'api', 
       url: '~api/dashboard/counce' 
      } 
     }, 
     subscriptions: { 
      autoLoad: true, 
      model: 'Wolf.model.Subscription', 
      proxy: { 
       type: 'api', 
       url: '~api/subscriptions' 
      } 
     }, 
     todos: { 
      autoLoad: true, 
      fields: [ 
       { 
        type: 'int', 
        name: 'id' 
       }, 
       { 
        type: 'string', 
        name: 'task' 
       }, 
       { 
        type: 'boolean', 
        name: 'done' 
       } 
      ], 
      proxy: { 
       type: 'api', 
       url: '~api/dashboard/tasks' 
      } 
     }, 
     bicategories: { 
      autoLoad: true, 
      model: 'Wolf.Bi.model.Category', 
      proxy: { 
       type: 'api', 
       url: 'api/v1/bi/categories' 
      } 
     }, 
     bicategoriesrecords: { 
      autoLoad: true, 
      model: 'Wolf.Bi.model.Records', 
      proxy: { 
       type: 'api', 
       url: 'api/v1/bi/views/test1/records' 
      } 
     } 
    } 
}); 

projectNameBi/SRC /보기/BIViews.js :

Ext.define('Wolf.Bi.view.test.BIViews', { 
    extend: 'Ext.Panel', 
    xtype: 'bi.testviews', 
    requires: [ 
     'Ext.DataView' 
    ], 
// cls: 'dashboard-main-chart shadow', 
    height: 380, 
    bodyPadding: 15, 
    title: 'List', 
    layout: { 
     type: 'vbox', 
     align: 'stretch' 
    }, 
// tools: [ 
//  { 
//   type: 'wrench', 
//   toggleValue: false, 
//   listeners: { 
//    click: 'onRefreshToggle' 
//   } 
//  } 
// ], 
    columns: [ 
     { 
      header: 'Name', 
      dataIndex: 'name' 
     } 
    ], 
    items: [ 
     { 
      xtype: 'dataview', 
      bind: { 
       store: '{bicategoriesrecords}' 
      }, 
      itemTpl: new Ext.XTemplate(
//     '<tpl for=".">', 
        '<div style="margin-bottom: 10px;" class="thumb-wrap">', 
        '<br/><span>name: </span><span>{name}</span>', 
        '<br/><span>id: </span><span>{id}</span>', 
        '<br/><span>amount: </span><span>{amount}</span>', 
        //'<tpl for="views"><b>{label}</b></tpl>', 
        '</div>' 
//     '</tpl>' 
        ) 
     } 
    ] 

}); 

그리고이 코드를 가져옵니다 그러한 결과의 결과를 얻는 데이터 :

https://postimg.org/image/hf5b0ac5v/

이 데이터를 페이지 매김이있는 테이블에 표시하려고합니다. 이것을 어떻게 성취합니까? 나는 너에게 도움을 요청하고있다.

나는에 BIViews.js을 변경

Ext.define('Wolf.Bi.view.test.BIViews', { 
    extend: 'Ext.grid.Grid', 
    xtype: 'bi.testviews', 
    columns: [{ 
      text: 'Id', 
      dataIndex: 'id', 
      sortable: false, 
      flex: 1 
     }, { 
      text: 'Name', 
      dataIndex: 'name', 
      sortable: false, 
      flex: 1 
     }, { 
      text: 'Amount', 
      dataIndex: 'amount', 
      sortable: false, 
      flex: 1 
     }], 
    bind: { 
     store: '{bicategoriesrecords}' 
    }, 
    dockedItems: [{ 
      xtype: 'pagingtoolbar', 
      bind: { 
       store: '{bicategoriesrecords}' 
      }, 
      dock: 'bottom', 
      displayInfo: true 
     }] 
}); 

나는 테이블 헤더를 볼 수 있지만, 데이터가로드되지, 무슨 잘못?

+0

게시 한 이미지 링크를 따라갈 때 개인 정보 오류가 발생합니다. 또한, [Fiddle] (https://fiddle.sencha.com/)에 대한 예제를 작성하면 많은 도움이됩니다. –

+0

지금 사용해보세요. 이 예제를 구현하기 위해 JSFiddle에서 열심히하겠습니다. 여기서는 admin 템플릿을 사용하기 때문에 실제로 어떻게 senchafiddle에 표시할지 모릅니다. 나는 이것을 사용하고 있습니다 http://examples.sencha.com/extjs/6.0.0/examples/admin-dashboard/#dashboard – rad11

답변

1

당신이 필요로하는 소리는 Ext.toolbar.Paging입니다. 이제 데이터보기과 함께 작동하는지 모르겠으므로 표로 변경했습니다.. 바이올린 예제가 없으면 테스트 할 수 없지만 다음과 같이 보일 것입니다.

items: [ 
    { 
     xtype: 'grid', // changed from 'dataview' to 'grid'. 
     bind: { 
      store: '{bicategoriesrecords}' 
     }, 
     itemTpl: new Ext.XTemplate(
      '<div style="margin-bottom: 10px;" class="thumb-wrap">', 
      '<br/><span>name: </span><span>{name}</span>', 
      '<br/><span>id: </span><span>{id}</span>', 
      '<br/><span>amount: </span><span>{amount}</span>', 
      '</div>' 
     ), 
     dockedItems: [{ 
      xtype: 'pagingtoolbar', 
      bind: { 
       store: '{bicategoriesrecords}' 
      }, 
      dock: 'bottom', 
      displayInfo: true 
     }] 
    } 
] 

시도해보십시오.

+0

답장을 보내 주셔서 감사합니다. 가까운 사이라고 생각하지만 변경 후에 데이터 표가 생성되지 않습니다. , 어떤 헤더 테이블도. 나는 이제 빈 패널을 가지고 콘솔은 분명하다. – rad11

+0

_testviews_이 _panel_ 인 것을 확인했습니다. 그것을 _grid_로 만드시겠습니까? 이미 _columns_ config가 있습니다. 그런 다음 _bind_ 및 _dockedItems_ 구성을 해당 표 패널로 이동하십시오. _itemTpl_을 제거하십시오. 죄송합니다. 실제로 작동하지 않으면 더 이상 할 수 없습니다. 테스트 할 방법이 없습니다. –

+0

내 질문을 편집했는데 도움이 될만한가요? – rad11