欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ExtJS Grid使用SimpleStore、多选框的方法

程序员文章站 2022-06-17 17:01:31
复制代码 代码如下:/// ext.onready(function(){ va...
复制代码 代码如下:

///<reference path="./vswd-ext_2.0.2.js" />
ext.onready(function(){
var data = [
[1,"wilson.fu",10],
[2,"wilson.fu2",20],
[3,"wilson.fu3",30]
];

var sqldata = new array() ;
for(var i=0;i<10;i++)
{
sqldata.push([i.tostring(),"wilson.fu" + i.tostring(),10*i]);
}

var sm = new ext.grid.checkboxselectionmodel({handlemousedown:ext.emptyfn});
var cm = new ext.grid.columnmodel([
sm,
{header:"编号",dataindex:"id",sortable:true},
{header:"姓名",dataindex:"name"},
{header:"排序值",dataindex:"ordernum",sortable:true}
]);

var store = new ext.data.simplestore({
fields:[
{name:"id"},
{name:"name"},
{name:"ordernum"}
]
});

store.loaddata(sqldata);

var gd = new ext.grid.gridpanel({
renderto:"grid",
cm:cm,
sm:sm,
store:store,
loadmask:true
});

ext.get("btn").on("click",function(){
var selections = gd.getselectionmodel().getselections();
debugger
//得到选择的行的值
});

});