Extjs 4.x 为GridPanel动态添加一行数据

Extjs 4.x 为GridPanel动态添加一行数据,第1张

//声明对应grid的Record对象

var ItemRecord = Ext.data.Record.create([

{name:'itemid'},

{name:'itemcode'},

{name:'itemname'},

{name:'price'},

{name:'mark'}

])

//点新增按钮时则执行类似如下函数

function addNewLine2Grid(grid){

var rec = new ItemRecord({ //实例化Record对象,并赋予各字段初始值

'itemid': 0,

'itemcode': '',

'itemname': '',

'price': 0.00,

'mark': ''

})

grid.store.insert(grid.store.getCount(), rec) //插入新行作为grid最后一行

grid.getView().refresh()//刷新

//grid.plugins[1].startEditing(grid.store.getCount()-1,4)//编辑最后一行第4列

}

function addColumn(){

var grid = Ext.getCmp('gridPanelID')

var stores = grid.getStore()

var recordType = grid.getStore().recordType

var data = new recordType()

grid.stopEditing()

stores.insert(0, data)

stores.sort()

grid.getView().refresh()

grid.startEditing(0, 0)

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11786816.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存