PDA

View Full Version : ???????? convert ???



Tommy1969
26 Jun 2010, 4:01 AM
store ????????????? convert ???????????:-/
???????????????????????????????????



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- Ext JS -->
<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js"> </script>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/ext-all.js"> </script>

<script type="text/javascript">
Ext.BLANK_IMAGE_URL = 'http://extjs.cachefly.net/ext-3.2.1/resources/images/default/s.gif';
</script>

<script>
Ext.onReady(function() {
var store = new Ext.data.ArrayStore({
fields: [
'f1',
'f2',
{
name: 'tt',
convert: function(v, rec) {
console.log('called');
return rec[0] + ' - ' + rec[1];
}
}
],
data: [
['a', 'b'],
['c', 'd']
]
});
store.add(new store.recordType({f1: 'e', f2: 'f'}));

console.log('0: ' + store.getAt(0).get('tt'));
console.log('1: ' + store.getAt(1).get('tt'));
console.log('2: ' + store.getAt(2).get('tt'));
});
</script>

</head>
<body>
</body>
</html>



# ??? console ???????? Web ???????????

integra
28 Jun 2010, 8:04 PM
Ext.data.Store#add?????????????reader?????????????????Ext.data.Store#insert????
Ext.data.Store#load?#loadData?reader??????????
?????????????????????????????????
?add,insert? (Record??????????)?????Record?Store??????
?load,loadData? (dataObject??????????)?????Reader????Record?????Store??????

loadData??????????


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- Ext JS -->
<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js"> </script>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/ext-all.js"> </script>

<script type="text/javascript">
Ext.BLANK_IMAGE_URL = 'http://extjs.cachefly.net/ext-3.2.1/resources/images/default/s.gif';
</script>

<script>
Ext.onReady(function() {
var store = new Ext.data.ArrayStore({
fields: ['f1','f2',{
name: 'tt',convert: function(v, rec) {
console.log('called');
return rec[0] + ' - ' + rec[1];
}
}],
data: [
['a', 'b'],
['c', 'd']
]
});
store.loadData([['e', 'f']], true);

console.log('0: ' + store.getAt(0).get('tt'));
console.log('1: ' + store.getAt(1).get('tt'));
console.log('2: ' + store.getAt(2).get('tt'));
});
</script>

</head>
<body>
</body>
</html>

Tommy1969
29 Jun 2010, 2:24 AM
?????????????????????????

loadData ??????????????????????????????????