PropertyGrid不支持store动态绑定的折中解决办法

官方说PropertyGrid的store属性应该隐去的
在svn里面已经隐去了
但是docs里还有
他们说因为什么原因所以这个只是个隐含属性,我忘记了
折中解决如下:


x.xml

<dataset>
<property><name>x</name><value>1</value></property>
<property><name>S</name><value>2</value></property>
</dataset>



js

var record = Ext.data.Record.create([
    {name: 'name', mapping : "name"},
    {name: 'value', mapping : "value" }
  ]);


  var pstore = new Ext.data.Store({
    url: 'x.xml',
    reader: new Ext.data.XmlReader({record: 'property'}, record),
    autoLoad: true,
    listeners: {
      load: function(store, records){

        PPGsource = {};

        for(var i = 0; i < records.length; i++){
          PPGsource[records[i].get('name')]=records[i].get('value');
        }

        propertyGrid = new Ext.grid.PropertyGrid({
          width:700,
          autoHeight:true,
          frame: false,
          source: PPGsource
        });

                                     propertyGrid.render("x-www.dc9.cn");

      }
    }
  });



真的,用监听的方式就好啦
然后取值用alert(PPGsource[records[0].get('name')]);
或者alert(PPGsource["x"]);


原来只需要定义一下source对象,propertyGrid中属性值改变的时候source对象中的相应值就会发生改变,想要获得propertyGrid的值则仅仅需要直接从这个对象中读取数值即可。


居然是这么简单容易的方法……我花了两天时间到处找这个问题的解决方案,快哭了……

var PPGsource = {
'x' : '1',
's' : '2',
};
propertyGrid = new Ext.grid.PropertyGrid({
width:700,
autoHeight:true,
frame: false,
source: PPGsource
});

要读取的话只需要这样:
alert(PPGsource['x']);

你可能感兴趣的:(xml,SVN,ext)