Shr*_*dit 7 javascript grid extjs
我是Ext JS的新手.我正在使用一个网格面板,当我选择/单击任何行时,与网格下面的面板中显示与所选行相关的某些数据.此外,当窗口加载时,默认情况下应选择/突出显示第一个窗口.目前,网格和面板正确显示.甚至与所选行相关的数据也会显示在面板中,但行不会突出显示.我已经尝试了grid.focusRow(0)&grid.getRow(0).highlight()方法,但它们没有用.以下是我的代码.
//the js file code
initComponent : function() { //within the window instance
var single = false;
var store = new Ext.data.XmlStore({//all necessary fields added}); //store
HttpUtil.syncCall(this.url, "GET", this.loadStore, store,this);
var acctTplMarkup = [//the fields here are displayed on row selection ];
/*The template for displaying the details of the selected row */
this.acctTpl = new Ext.Template(acctTplMarkup);
//check for request type, if type is range of checks create the grid
if (single == false) {
var gridView = new Ext.grid.GridView();
var colModel = new Ext.grid.ColumnModel([ {
header : 'Status',
dataIndex : 'status'
}, {
header : 'Message',
dataIndex : 'message'
} ]);
var selModel = new Ext.grid.RowSelectionModel({
singleSelect : true
});
grid = new Ext.grid.GridPanel({
...
listeners : {
render : function(grid) {
Ext.getCmp('check').store.on('load',function(store, records, options) { //check is the id value for the window instance
grid.getSelectionModel().selectFirstRow();
});
}
}
}); //gridPanel
} //if
/* If request type is range select then display the grid */
...
if (single == false) {
grid.getSelectionModel().on('rowselect', function(sm, rowIdx, r) {
Ext.getCmp('check').acctTpl.overwrite(Ext.getCmp('detailPanel').body, r.data);
}); //rowselect
} //if
Ext.apply(this, {
...
listeners : {
'afterrender' : function(){
Ext.getCmp('check').acctTpl.overwrite(Ext.getCmp('detailPanel').body, this.store.getAt(0).data,true);
}
}
});
Check.superclass.initComponent.apply(this, arguments);
}, //initComponent
Run Code Online (Sandbox Code Playgroud)
来自数据存储区的数据已正确加载和显示,但只是该行未突出显示.谁能告诉我哪里出错了?
Li0*_*liQ 11
没有getRow方法Ext.grid.GridPanel.但是,有一个Ext.grid.GridView.
要突出显示该行,您应该执行以下操作:
var row = grid.getView().getRow(0); // Getting HtmlElement here
Ext.get(row).highlight(); // Getting element wrapper and using its "highlight" method
Run Code Online (Sandbox Code Playgroud)
要执行行选择,您使用网格的SelectionModel:
grid.getSelectionModel().selectRow(0)
Run Code Online (Sandbox Code Playgroud)
组件:Ext.grid.Panel
版本:4.0.0
要选择一个项目并删除以前的选择:
grid.getSelectionModel().select(0);
Run Code Online (Sandbox Code Playgroud)
要选择一个项目并保留以前的选择:
grid.getSelectionModel().select(0, true);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39060 次 |
| 最近记录: |