0

I am just begining to learn Sencha.

I have an asmx that returns a List so the xml looks like;

<Result>
  <string>One</string>
  <string>Two><string>
</Results>

Now all I want to do is show that in a List.

So my Sench code looks like;

Ext.define('ListItem', {
    extend: 'Ext.data.Model',
    config: {
        fields: ['text']
    }
});

var treeStore = Ext.create('Ext.data.TreeStore', {
    model: 'ListItem',
    defaultRootProperty: 'items',
    proxy: {
        type: 'ajax',
        url: 'http://localhost:81/MyASMX.asmx/Test'
    }
});


Ext.application({
    name: 'Sencha',

    launch: function () {
        Ext.create('Ext.NestedList', {
            fullscreen: true,
            store: treeStore,
            detailCard: {
                html: 'You are viewing the detail card!'
            }
        });
    }
});

But I get an empty list with a title bar that is also empty.

griegs
  • 22,624
  • 33
  • 128
  • 205
  • Stupid question first, have you done basic troubleshooting with Wireshark/Fiddler to prove that the response is actually what you think it is? – M.Babcock Mar 30 '12 at 00:17
  • The response I get is not what i am expecting no. seems that the result from the asmx is always in xml for some reason. i would like json but i get "{'stringlist':[{'value':'first'}, {'value':'second'}, {'value':'third'}]}" on some tests – griegs Mar 30 '12 at 00:25
  • It's been a while since I've used ASMX (since it is depreciated), but I'm pretty sure it only supports XML. -- Re your comment edit: take a look at JSON.NET to serialize your object to JSON. – M.Babcock Mar 30 '12 at 00:25

1 Answers1

0

With .Asmx you can also bind xml to your treestore here is the code that might be help you

function BindData(dataxml)
{

   dataxml = dataxml.replace(/&gt;/g, ">");
   dataxml = dataxml.replace(/&lt;/g, "<");
  var doc;
  if (window.ActiveXObject) {         //IE
    var doc = new ActiveXObject("Microsoft.XMLDOM");
    doc.async = "false";
    doc.loadXML(dataxml);
  } else {                             //Mozilla
    var doc = new DOMParser().parseFromString(dataxml, "text/xml");
  }
  var store = new Ext.getStore('treestore');
  store.removeAll();
  var DataLen = doc.getElementsByTagName('FirstNode').length;
     for (var i = 0; i < DataLen; i++) {
    var arrnodename = doc.getElementsByTagName('nodeName')[i].firstChild.nodeValue.replace(/\"/g, '');
  var arrnodename2 = doc.getElementsByTagName('nodeName2')[i].firstChild.nodeValue.replace(/\"/g, '');
    store.add({ C1: arrnodename[0], C2: arrnodename2[0]});
     }
}
Sagar Modi
  • 770
  • 2
  • 7
  • 29