在extjs中向行添加行

时间:2015-03-19 06:06:09

标签: javascript grid extjs3

所以我可能正在做的事情就是通过外部javascript向ExtJS 3.4中创建的已经存在的网格添加行更加复杂。到目前为止,我没有选择并且没有帮助......所以任何新想法都会受到高度赞赏......

到目前为止我所拥有的是

var myStore = new Ext.data.ArrayStore({
    fields: ['fullname', 'first'],
    idIndex: 0 // id for each record will be the first element
});

// create a Record constructor:
var rt = Ext.data.Record.create([
    {name: 'fullname'},
    {name: 'first'}
]);

var myStore = new Ext.data.Store({
    // explicitly create reader
    reader: new Ext.data.ArrayReader(
        {
            idIndex: 0  // id for each record will be the first element
        },
        rt // recordType
    )
});

var myData = [
    [1, 'Fred Flintstone', 'Fred'],  // note that id for the record is the first element
    [2, 'Barney Rubble', 'Barney']
];
myStore.loadData(myData);

var defaultData = {
    fullname: 'Full Name',
    first: 'First Name'
};
var recId = 100; // provide unique id for the record
var r = new myStore.recordType(defaultData, ++recId); // create new record
myStore.insert(0, r); // insert a new record into the store (also see add)

现在这已经足够好了,如果网格在当前页面中......让我的生活变得疯狂的是从父窗口(window.opener)获取Store值,我尝试通过

访问Ext对象
Ext.getCmp(window.opener.document.getElementById(window.opener.document.getElementByID('MyRecord'))).getStore();

window.opener.Ext.getCmp(getElementById('MyRecord')).getStore();

window.opener.Ext.getCmp('MyRecord').getStore();

似乎没有任何作用......请帮助!

0 个答案:

没有答案