2017-10-20 177 views
0

我想知道是否可以动态创建网格视图。我会尽我所能来解释......动态创建网格EXTJS

我目前有有不同的区域数据库表中,我创建了解决此一格,你可以添加新条目到这个网,这反过来将其添加到表..

我也有包含姓名,电话号码联络人数据库表,并使用所有的区域作为一个下拉。您可以再次通过网格在此表格中添加新条目。

最后我有一个第三格栅,显示所有接触的人,分解到自己的区域。我遇到的问题是如何使其动态?目前我已经硬编码区域标题和填充一个正确过滤的网格,但是如果某人完全添加了新的区域会怎样?我如何使用适当的过滤器为新添加的区域创建标题和网格?

第三格栅代码:

Ext.define('myproject.example', { 
    extend: 'Ext.form.Panel', 
    alias: 'widget.********', 

    requires: [ 
     'store.exampleStore' 
    ], 
    modal: true, 
    draggable: true, 
    header: { 
     title: 'Technical Advisors Contact Information', 
     height: 55, 
     items: [{ 
      xtype: 'button', 
      text: 'X', 
      listeners: { click: 'onModalX' } 
     }] 
    }, 
    scrollable: true, 
    align: 'center', 
    floating: true, 
    width: 1500, 
    height: 800, 

    items: [{ 
     xtype: 'grid', 
     title: 'Region: ME', 
     scrollable: true, 
     collapsible: true, 
     store: { type: 'exampleStore', filters: [{ property: 'Region', value: 'ME' }, { property: 'Active', value: 'true' }] }, 
     columns: [{ 
      text: 'Contact', 
      dataIndex: 'ContactName', 
      sortable: true, 
      flex: 2 
     }, { 
      text: 'Office #', 
      dataIndex: 'Office', 
      sortable: true, 
      flex: 1 
     }, { 
      text: 'Home #', 
      dataIndex: 'Home', 
      sortable: true, 
      flex: 1 
     }, { 
      text: 'Pager #', 
      dataIndex: 'Pager', 
      sortable: true, 
      flex: 1 
     }, { 
      text: 'Cellular #', 
      dataIndex: 'Cellular', 
      sortable: true, 
      flex: 1 
     }, { 
      text: 'Area', 
      dataIndex: 'Region', 
      sortable: true, 
      flex: 3 
     }] //continues... 
+0

您正在使用什么版本的ExtJS的吗? – tommyO

+0

我正在使用extjs 6.2 – TigerDave

回答

-1

对于第一个,你需要得到客户端的数据(在浏览器中)。这可以通过ajax请求(jsonp,ext.direct,rest等)完成。

然后你就可以将数据加载到你的店:

grid.store.loadData(result.data); 

您可以手动做到这一点,或者阅读有关ExtJS的代理。最简单的方法是rest-proxy

+0

不是我在找什么。我正在寻找动态构建网格,而不是将数据添加到网格中。 我想运行数据的foreach来动态构建我需要的所有网格,现在我需要的网格数量是未知的,并且随着用户输入新数据而不断变化。 – TigerDave

+0

对不起,误解了你。 请检查重新配置方法 用法示例:https://github.com/basis-company/tarantool-admin/blob/master/public/admin/js/Space/Collection.js#L166 – user3516761