Extjs从数据库获取Id并将其传递给组件

时间:2013-05-22 03:20:08

标签: extjs extjs4

我面临的问题是。我有一个查询数据库并获取汽车信息的表单,我想获得该数据的唯一ID并将其传递给已经制作的组件。

 layout : 'fit',
 items : [{
       xtype: 'cargrid',
       autoScroll: true
       //here I want the ID to be passed to this cone
 }]

2 个答案:

答案 0 :(得分:0)

也许,你想在网格上显示行的ID吗?

  1. 您需要在商店/模型上获取它。在数据存储上定义一个“id”字段。
  2. <强> MODEL:

    fields: [
                 {name: 'idRow'},
                 {...}
    ]
    
    1. 在网格上,在dataIndex上定义一个名称为“store field id”的列:
    2. 网格视图:

      columns: [{
              header: "Identificator",
              dataIndex: 'idRow'
          },
              {...} 
      ]
      

      编辑:

      如果您想覆盖de ID:

      请参阅链接所属:itemID

      并在评论中:(复制和粘贴)

      示例:

      var c = new Ext.panel.Panel({ //
          height: 300,
          renderTo: document.body,
          layout: 'auto',
          items: [
              {
                  itemId: 'p1',
                  title: 'Panel 1',
                  height: 150
              },
              {
                  itemId: 'p2',
                  title: 'Panel 2',
                  height: 150
              }
          ]
      })
      p1 = c.getComponent('p1'); // not the same as Ext.getCmp()
      p2 = p1.ownerCt.getComponent('p2'); // reference via a sibling
      

      <强>注释:

          Ext.apply(c, {
              itemId : 'p3'
          }
      

答案 1 :(得分:0)

一旦渲染,您就无法更改组件ID。您可以在创建组件之前进行分配。

解决方法:

  1. 只需删除该组件,然后使用新ID重新创建。
  2. 动态创建组件并添加require父组件。
  3. 据我了解,its not possible to change component ID after rendering of component

    由于