ext如何通过xml格式来传值

解决方案 »

  1.   

    我自己找到一个方法顶一下
    建一个record
      var manger=Ext.data.Record.create([
         {name:"name",type:"String"},
         {name:"sex",type:"String"}
       ]);
    给manger赋值
       var boy=new manger({
              name:"龙",
              sex:"男"
       }
    建xmlstore
       var data=new Ext.data.XmlStore();
       data.add(boy);   //store赋值
       //提交数据
    Ext.Ajax.request({url:"dataservlet",xmlDate:data});
      

  2.   

    官方实例
    var Employee = Ext.data.Record.create([
       {name: 'name', mapping: 'name'},     // "mapping" property not needed if it is the same as "name"
       {name: 'occupation'}                 // This field will use "occupation" as the mapping.
    ]);
    var myReader = new Ext.data.XmlReader({
       totalProperty: "results", // The element which contains the total dataset size (optional)
       record: "row",           // The repeated element which contains row information
       idProperty: "id"         // The element within the row that provides an ID for the record (optional)
       messageProperty: "msg"   // The element within the response that provides a user-feedback message (optional)
    }, Employee);
    This would consume an XML file like this:<?xml version="1.0" encoding="UTF-8"?>
    <dataset>
     <results>2</results>
     <row>
       <id>1</id>
       <name>Bill</name>
       <occupation>Gardener</occupation>
     </row>
     <row>
       <id>2</id>
       <name>Ben</name>
       <occupation>Horticulturalist</occupation>
     </row>
    </dataset>