Extjs从数据库获取Id并将其传递给组件(Extjs Get Id from database and pass it to component)
我面临的问题是。 我有一个查询数据库并获取汽车信息的表单,我想获得该数据的唯一ID并将其传递给已经制作的组件。
layout : 'fit', items : [{ xtype: 'cargrid', autoScroll: true //here I want the ID to be passed to this cone }]Problem I am facing is. I have a form that query the database and get information on cars, I would like to get the Unique Id of that data and pass it to an already made component.
layout : 'fit', items : [{ xtype: 'cargrid', autoScroll: true //here I want the ID to be passed to this cone }]最满意答案
也许,你想要在网格上显示行的ID吗?
你需要在商店/模型上得到它。 在数据存储上定义一个“id”字段。模型:
fields: [ {name: 'idRow'}, {...} ] 在网格上,在dataIndex上定义一个列,其名称为“store field id”:网格视图:
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' }Maybe, did u want to show the id of the row on the grid ?
You need to get it on the store/model. Define one 'id' field on the data store.MODEL:
fields: [ {name: 'idRow'}, {...} ] On the grid, define one column, with same name of "store field id" on the dataIndex:GRID VIEW:
columns: [{ header: "Identificator", dataIndex: 'idRow' }, {...} ]EDIT:
If you want overwrite de ID:
See the link belong: itemID
and in the comment: (copy&paste)
Example:
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 siblingComment:
Ext.apply(c, { itemId : 'p3' }更多推荐
发布评论