新手求教育 EXTJS问题 版本4.2
extjs吧
全部回复
仅看楼主
level 2
lyy2235533 楼主
//预加载提高运行速度
Ext.require([
'Ext.grid.*',
'Ext.data.*'
]);
Ext.onReady(function(){
//Ext.define在这里是定义一个类
Ext.define('MyData',{
extend: 'Ext.data.Model',
fields: [
//第一个字段需要指定mapping,其他字段,可以省略掉。
{name:'UserName',mapping:'UserName'},
'Sex',
'Age',
'XueHao',
'BanJi'
]
});
//创建数据源
var store = Ext.create('Ext.data.Store', {
model: 'MyData',
proxy: {
//异步获取数据,这里的URL可以改为任何动态页面,只要返回JSON数据即可
type: 'ajax',
url: 'javascript/mydata.json',
reader: {
type: 'json',
root: 'items'
}
},
autoLoad: true
});
//创建Grid
var grid = Ext.create('Ext.grid.Panel',{
store: store, //读取数据源
columns: [
{text: "姓名", width: 120, dataIndex: 'UserName', sortable: true},
{text: "性别", flex: 1, dataIndex: 'Sex', sortable: false},
{text: "年龄", width: 100, dataIndex: 'Age', sortable: true},
{text: "学号", width: 100, dataIndex: 'XueHao', sortable: true},
{text: "班级", width: 100, dataIndex: 'BanJi', sortable: true}
],
autoHeight: true,
width:480,
x:20,
y:40,
title: 'ExtJS4 Grid示例',
renderTo: 'demo',
//事件监听
/**
listeners : {
'celldblclick':function(grid, rowIndex, columnIndex,item,e){
alert('ok');
}
},*/
//grid属性配置
viewConfig: {
/**
forceFit:true,//当行大小变化时始终填充满
enableRowBody:true,//可以用两行tr来表示一行数据
showPreview:true,//初始显示预览效果,这个是自定义的属性
getRowClass : function(record, rowIndex, p, store){//CSS class name to add to the row.获得一行的css样式 */
stripeRows: true //实现隔行换色
}
});
grid.on('celldblclick',function(grid,rowIndex,colIndex){
alert(rowIndex);
alert(grid.getStore().getAt(rowIndex));
var rec = grid.getStore().getAt(rowIndex);
alert("保存 "+rec.get('name'));
});
就是在这里 总是获取不到grid.getStore().getAt(rowIndex) 求解答
});
2013年08月15日 03点08分 1
1