Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: DataReader ? ? ?

  1. #1

    Exclamation DataReader ? ? ?

    Hello all !

    I'm very new on ExtJS and I need your help.

    I try to create an application witch is devided in two parts.

    The first one is the PHP that generating an XML File :

    PHP Code:
    <?php
    header
    ("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
    header("Last-Modified: " gmdate"D, d M Y H:i:s" ) . "GMT" );
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    header("Content-Type: application/xml");
     
    echo 
    '<?xml version="1.0" encoding="UTF-8"?>';
    echo 
    '<dataset>';
    echo 
    '<total>';
    echo 
    $total;
    echo 
    '</total>';
    foreach(
    $data as $dt)
    {
    echo 
    '<data>';
    echo 
    '<id>';
    echo 
    $dt['Group']['id'];
    echo 
    '</id>';
    echo 
    '<name>';
    echo 
    $dt['Group']['name'];
    echo 
    '</name>';
    echo 
    '</data>';
    }
     
    echo 
    '</dataset>';
    ?>
    The above code is working perfectly !
    It generating the XML correctly;

    the XML Code that I'm getting back is the following one :

    Code:
    <?xml version="1.0" encoding="UTF-8" ?> 
    <dataset>
     <total>3</total> 
     <data>
     <id>1</id> 
     <name>Administrators</name> 
     </data>
     <data>
     <id>2</id> 
     <name>Managers</name> 
     </data>
     <data>
     <id>3</id> 
     <name>Users</name> 
     </data>
     </dataset>
    The second part is the ExtJS.

    Is already installed in my page and I try to load the xml on it but I have problem

    The code is the following :

    Code:
     
    Ext.onReady(
     function()
     {
     
      var groupDS = new Ext.data.Store(
       {
        reader: new Ext.data.XmlReader(
         {
          record: 'data',
          id: 'id'
         },
         [
          'id',
          'name'
         ]
        ),
        url: 'http://www.myserveraddress.dch/Groups/view'
       }
      );
     
      groupDS.load();
     
      var vp = new Ext.Viewport(
        {
         renderTo: Ext.getBody,
         layout: 'border',
         items:
         [
          {
           region: 'north',
           xtype: 'toolbar',
           height: '25',
           items:
           [
            menuToolBar
           ]
          },
          {
           region: 'west',
           margins: '5 0 5 5',
           split: true,
           width: 280,
           closable: true,
           layout: 'accordion',
           layoutConfig:
           {
            animate: true,
            activeOnTop: false,
            fill: true
           },
           items:
           [
            {
             title: "Users & Groups",
             xtype: 'panel',
             items:
             [
              {
               title: "Example panel 1",
               collapsible: true,
               xtype: 'form',
               items:
               [
                {
                 xtype: "combo",
                 fieldLabel: "Groups",
                 name: "groups",
                 store: groupDS,
                 mode: 'local',
                 displayField: 'name'
                }
               ]
              },
              {
               title: "Example panel 2",
               collapsible: true,
               xtype: 'panel',
               height: 200
              },
              {
               title: "Example panel 3",
               collapsible: true,
               xtype: 'panel',
               height: 200
              },
              {
               title: "Example panel 4",
               collapsible: true,
               xtype: 'panel',
               height: 200,
               id: 'panel4'
              }
     
             ]
            },
            {
             title: "Again hello !"
            }
           ]
          },
          {
           region: 'center',
           xtype: 'panel',
           id: 'Hello'
          },
          {
           region: 'south',
           xtype: 'toolbar',
           height: '25',
           items:
           [
            statusToolBar
           ]
          }
         ]     
        }
       );
     }
    );
    The problem is that I can't get the data from the XmlReader and place it into the combo ! !

    I have try many methods but It can't work ! ! !

    What can I do ? ? ?

    Kind regards Merianos nikos

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    It looks OK (apart from Example panel 1 missng autoHeight:true).

    Try adding load and loadexception listeners to the store and see which one fires.

  3. #3

    Default

    What I have try to do is

    Code:
    var groupDS = new Ext.data.Store(
       {
        reader: new Ext.data.XmlReader(
         {
          record: 'data',
          id: 'id'
         },
         [
          'id',
          'name'
         ]
        ),
        url: 'http://www.hotelcms.dch/Groups/view',
        load: function()
        {     
            alert("Loaded");
        }
       }
      );
    and it's working the load

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    That is not a listener.

    Try:
    Code:
    var groupDS = new Ext.data.Store({
      reader: new Ext.data.XmlReader({
        record: 'data',
        id: 'id',
        fields: ['id', 'name']
      }),
      url: 'http://www.hotelcms.dch/Groups/view',
      listeners: {
        load: function(){
          alert("Loaded");
        },
        loadexception: function(){
          alert("Not loaded");
        }
      }
    });
    (in Ext 3 it would be better to use the exception intead of loadexception event)

  5. #5

    Default

    Quote Originally Posted by merianos View Post
    What I have try to do is

    Code:
    var groupDS = new Ext.data.Store(
       {
        reader: new Ext.data.XmlReader(
         {
          record: 'data',
          id: 'id'
         },
         [
          'id',
          'name'
         ]
        ),
        url: 'http://www.hotelcms.dch/Groups/view',
        load: function()
        {     
            alert("Loaded");
        }
       }
      );
    and it's working the load

    The loadexception does not fire

  6. #6

    Default

    Quote Originally Posted by Condor View Post
    That is not a listener.

    Try:
    Code:
    var groupDS = new Ext.data.Store({
      reader: new Ext.data.XmlReader({
        record: 'data',
        id: 'id',
        fields: ['id', 'name']
      }),
      url: 'http://www.hotelcms.dch/Groups/view',
      listeners: {
        load: function(){
          alert("Loaded");
        },
        loadexception: function(){
          alert("Not loaded");
        }
      }
    });
    (in Ext 3 it would be better to use the exception intead of loadexception event)
    Again with your way the load is the one that works

  7. #7

    Default

    Any solution to my problem ? ? ?

  8. #8

    Default

    I wander if I need any Serial Key to use the ExtJS.

    I hope tthat I don't need something like that eh ? ? ? ?

  9. #9
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    No, you don't need a serial key.

    Can you look at the parameters passed in the load event handler? How many records are returned?

  10. #10

    Default

    Quote Originally Posted by Condor View Post
    No, you don't need a serial key.

    Can you look at the parameters passed in the load event handler? How many records are returned?
    How can I do that ? ? ?

    I am very new to ExtJS and I do not have the expirience on how can I do it !

    Kind regards
    Merianos Nikos

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •