PDA

View Full Version : Grid????????????????



Yoshy
25 Oct 2009, 10:21 PM
Yoshy??????
?????????

??????????????????????????
?????PHP???????????????????????????????????????
???????????????????

JS???????????????????????????
????????????????PHP??????????JS?????????????

?????????????

var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel
([
sm
,{header:'???' ,dataIndex:'tx_item1,width:50 ,align:'right'}
,{header:'???' ,dataIndex:''tx_item2' ,width:100 ,align:'left'}
,{header:'???' ,dataIndex:'tx_item3' ,width:200 ,align:'left'}
,{header:'???' ,dataIndex:'tx_item4' ,width:200 ,align:'left'}
,{header:'???' ,dataIndex:'tx_item5' ,width:200 ,align:'left'}
]);
cm.defaultSortable = true;
Ext.getCmp('grid_list').reconfigure(ds,cm);

yuki
26 Oct 2009, 12:06 AM
?????????????


$cols = array(
array('header'=>'??1', 'dataIndex'=>'tx_item1', 'width'=>50, 'align'=>'right'),
array('header'=>'??2', 'dataIndex'=>'tx_item2', 'width'=>100, 'align'=>'left'),
...
);
echo json_encode($cols);

????????PHP????cols.php?????


Ext.Ajax.request({
url: 'cols.php',
callback: function(o,s,r){
if(s){
try{
var cols = Ext.decode(r.responseText);
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel(cols.unshift(sm));
cm.defaultSortable = true;
Ext.getCmp('grid_list').reconfigure(ds,cm);
}catch(e){
// ????
}
}
});

???????????

Yoshy
27 Oct 2009, 12:34 AM
??????????????
renderer?????????????????renderer????????????????????:((

,array('header'=>'??' ,'dataIndex'=>'am_price' ,'width'=> 80,'align'=>'right' ,'renderer'=>'function(val) { return to_comma(val);}')

?????PHP????????????????????

????Catch??????????????TypeError: this.renderer is undefined??????????
renderer??????????to_comma?JS???????????

yuki
27 Oct 2009, 2:04 AM
renderer?????????????????renderer????????????????????:((

,array('header'=>'??' ,'dataIndex'=>'am_price' ,'width'=> 80,'align'=>'right' ,'renderer'=>'function(val) { return to_comma(val);}')

?????PHP????????????????????

????Catch??????????????TypeError: this.renderer is undefined??????????
renderer??????????to_comma?JS???????????

?????????Ext.decode?=eval??renderer?????????????????????????renderer??????Ext.decode???????????????PHP??????JS?????????????PHP?????????????????'???"??????????????????????JS???????????????????PHP????????????????????????????Ext.decode??????????????????

?????????firebug??????????????????Ext???????????

function f(v){ console.log(v+" I'm function f!"); }

var a = '{"b": 1, "c":"f", "d":"function(v){console.log(v)}"}';
var b = Ext.decode(a);

console.dir(b); // ?????

b.c = Ext.decode(b.c);
b.d = Ext.decode(b.d);

console.dir(b); // c?d?function?

b.c("hello"); // "hello I'm functionf!" ???
b.d("hello"); // "hello" ???

Yoshy
28 Oct 2009, 1:15 AM
??????????????

??????????????????????
?????????

??1??????

Firefox?????????IE7?????????????

?????????????IE???'renderer'??????Ext.decode????????
??'undefined'??????????

??????
Before:function(val){return ConvDate(val);}
After:undefined

????[object Error]
??????????

FireFox????????????????????????????????????????
?????????????
????Ext???????3.0.3???

------------------------------------------------------------------------------
var json = Ext.decode(response.responseText);
var sm = new Ext.grid.CheckboxSelectionModel();
var cols = json.columns;
var recs = json.records;
var detail = Ext.data.Record.create(recs);
for(var i = 0 ; i < cols.length ; i++)
{
for (key in cols[i])
{
if(key == 'renderer')
{
alert('Before:' + cols[i][key]);
cols[i][key] = Ext.decode(cols[i][key]);
alert('After:' + cols[i][key]);
}
}
}
cols.unshift(sm);

yuki
28 Oct 2009, 3:09 AM
?????????:)


cols[i][key] = Ext.decode(cols[i][key]);

??????????


eval('cols[i][key]='+cols[i][key]);

????????IE??????????