Ext.data-GroupingStore/JsonStore/SimpleStore
发布时间:2020-12-16 19:59:47 所属栏目:百科 来源:网络整理
导读:Ext.data.GroupingStore 继承自Ext.data.Store,为Store增加了分组功能.其它用法与Store一致,惟一需要注意的是使用GroupingStore时必须指定sortInfo信息 增加了配置属性 groupField : String//用于分组的字段 groupOnSort : Boolean//如果为真,将依排序字段重
Ext.data.GroupingStore
var
arr
=
[[
1
,
'
本
'
,
'
拉登
'
],[
2
,
'
笨
'
,[
3
,
'
拉灯
'
]];
var reader = new Ext.data.ArrayReader( {id: 0 } , [ {name: ' name ' ,mapping: 1 } , {name: ' occupation ' ,mapping: 2 } ]); var store = new Ext.data.GroupingStore( { reader:reader, groupField: ' name ' , groupOnSort: true , sortInfo: {field: ' occupation ' ,direction: " ASC " } // 使用GroupingStore时必须指定sortInfo信息 } ); store.loadData(arr); // GridPanel以后会讨论,这儿使用它是为了直观的表现GroupingStore var grid = new Ext.grid.GridPanel( { ds:store, columns:[ {header: " name " ,width: 20 ,sortable: true ,dataIndex: ' name ' } , {header: " occupation " ,dataIndex: ' occupation ' } ], view: new Ext.grid.GroupingView( { forceFit: true , groupTextTpl: ' {text}({[values.rs.length]}{[values.rs.length>1?"Items":"Item"]}) ' } ), frame: true , width: 700 , height: 450 , collapsible: true , animCollapse: false , title: ' GroupingExample ' , renderTo: ' Div_GridPanel ' } );
/*
这是使用远程对象,返回内容与下面本地对象的data一致 varstore=newExt.data.JsonStore({ url:'jsoncallback.js', root:'rows', fields:['id','name','occupation'] }); store.load(); */ var store = new Ext.data.JsonStore( { data: { ' results ' : 2 , ' rows ' :[ { ' id ' : 1 , ' name ' : ' Bill ' ,occupation: ' Gardener ' } , { ' id ' : 2 , ' name ' : ' Ben ' ,occupation: ' Horticulturalist ' } ]} , autoLoad: true , root: ' rows ' , fields:[ ' id ' , ' name ' , ' occupation ' ] } ) // 目前请先略过gridpanel,以后再说 var grid = new Ext.grid.GridPanel( { ds:store, columns:[ {header: " id " ,width: 200 ,dataIndex: ' id ' } , {header: " name " , {header: " occupation " ,height: 350 , width: 620 , title: ' ArrayGrid ' , renderTo: ' Div_GridPanel ' } );
varstore
=
new
Ext.data.JsonStore(
{
data:[ [ 1 , ' Bill ' , ' Gardener ' ],[ 2 , ' Ben ' , ' Horticulturalist ' ] ], fields:[ {name: ' name ' ,mapping: 1 } , {name: ' occupation ' ,mapping: 2 } ] } ) vargrid = new Ext.grid.GridPanel( { ds:store, columns:[ {header: " name " , {header: " occupation " , renderTo: ' Div_GridPanel ' } );
链接自:http://www.phpweblog.net/susam119/archive/2007/12/07/2486.html
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |