ext 显示问题
悬赏:5 发布时间:2008-07-14 提问人:brinkmanyh (初级程序员)
Ext.onReady(function(){
// example of custom renderer function
function pctChange(val){
if(val > 0){
return '<span style="color:red;">未激活</span>';
}else if(val <= 0){
return '正常';
}
return val;
}
var recordType = Ext.data.Record.create([ {
name : 'id',
type : 'float',
mapping : 'id'
}, {
name : 'username',
type : 'string',
mapping : 'username'
}, {
name : 'pwd',
type : 'string',
mapping : 'pwd'
}, {
name : 'state',
type : 'float',
mapping : 'state'
}]);
// create the data store
var store = new Ext.data.Store( {
proxy : new Ext.data.HttpProxy( {
url : 'User/doGetUserList.action'
}),
// set up the JsonReader
reader : new Ext.data.JsonReader( {
root : 'list',
id : 'id'
}, recordType)
});
store.load();
var sm = new Ext.grid.CheckboxSelectionModel( {
singleSelect : false
});
// create the Grid
var grid = new Ext.grid.GridPanel({
store: store,
columns: [
new Ext.grid.RowNumberer(),
{id:'id',header: "id", width: 160, sortable: true, dataIndex: 'id'},
{header: "姓名", width: 75, sortable: true, dataIndex: 'username'},
{header: "密码", width: 75, sortable: true, dataIndex: 'pwd'},
{header: "状态", width: 75, sortable: true, renderer: pctChange, dataIndex: 'state'},
sm
]
});
grid.render('grid');
grid.getSelectionModel().selectFirstRow();
});
运行后数据有多条,但是只显示一条
采纳的答案
2008-07-17 yingwuhahahaha (初级程序员)
设置一下grid的height试下,有时不显示就是高度问题
提问者对于答案的评价:
谢谢,确实是height的问题
我最开始用viewport,设置了fit,所以没注意这个问题




