1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    2
    Vote Rating
    0
    vtmac is on a distinguished road

      0  

    Default Query Odata Feed

    Query Odata Feed


    Hi,

    is it possible to query a odata feed using Ext.data.Store ?
    I keep getting an parse error.
    Anyone knows how to do it ?

    thanks

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    More than likely. What does the feed look like? Got a URL?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    2
    Vote Rating
    0
    vtmac is on a distinguished road

      0  

    Default


    Thanks for your fast reply.
    For now its an internal odata feed.
    But its prety much like this one :
    http://services.odata.org/Northwind/Northwind.svc/
    http://services.odata.org/Northwind/Northwind.svc/Customers?$format=json
    if you can show me for example how to load the Customers (json format) to a data store to use it on a list would be awsome !

    Thanks in advance!

  4. #4
    Sencha Premium Member StaticVoidMain's Avatar
    Join Date
    Aug 2007
    Location
    Buenos Aires - Argentina
    Posts
    38
    Vote Rating
    0
    StaticVoidMain is on a distinguished road

      0  

    Lightbulb Query

    Query


    For querying you don't need much, the problem arises when you want to write to the store but, if it is just for reading you just need to configure store like this:
    var store = new Ext.data.JsonStore({
    root: 'd',
    url: 'http://services.odata.org/Northwind/Northwind.svc/Customers?$format=json',
    fields:[...],
    ...
    });
    This works as expected, i'm using it, i'm also working on an "OdataStore" (and corresponding OdataProxy) to support writing but is not finnished yet.

    I hope that helps a bit to clarify things.

  5. #5
    Sencha User JeremyCaney's Avatar
    Join Date
    May 2009
    Location
    Seattle, Washington
    Posts
    2
    Vote Rating
    0
    JeremyCaney is on a distinguished road

      0  

    Default


    We did some work on querying an OData store back with ExtJS 3.0 and ADO.NET Data Services 1.5. I hope to update this to work with ExtJS 4.0 and WCF Data Services at some point, but haven't had a chance to work on this yet. One of my co-workers posted some information on the approach we took previously, which may be of value.

    http://blogs.ignia.com/Levi.Fleischm...ices.rest.aspx

    Jeremy

  6. #6
    Sencha User
    Join Date
    Sep 2007
    Posts
    1
    Vote Rating
    0
    deepmime is on a distinguished road

      0  

    Default Odata

    Odata


    I plan on implementing this in the next month or so.

    If anyone else is working on this, please let me know. I would rather not reinvent the wheel but it will be good practice for me if anything.

    Any suggestions would be greatly appreciated. I think the trick will be updating I believe.

    If i'm successful, i'll post the link here.

  7. #7
    Sencha User dotnetwise's Avatar
    Join Date
    Mar 2010
    Location
    Iasi, Romania
    Posts
    31
    Vote Rating
    1
    dotnetwise is on a distinguished road

      0  

    Default


    I'm also interestead into it for Ext 4.0.2 - any progress so far?

  8. #8
    Sencha User
    Join Date
    May 2011
    Posts
    1
    Vote Rating
    0
    jcranwellward is on a distinguished road

      0  

    Default


    Bump!

    Im also interested in this topic, anything happend this year yet?

  9. #9
    Sencha User
    Join Date
    Jun 2010
    Location
    Brazil
    Posts
    10
    Vote Rating
    0
    facorreia is on a distinguished road

      0  

    Default


    I need to build front-end applications for WCF Data Services web services using the OData protocol.

    Is there any progress on a compatible store for this with CRUD support?

  10. #10
    Sencha User Oleg Dolzhansky's Avatar
    Join Date
    Nov 2011
    Location
    Almaty, Kazakhstan
    Posts
    3
    Vote Rating
    0
    Oleg Dolzhansky is on a distinguished road

      0  

    Default


    Please see this very basic implementation of OData Protocol which WCF Data Services use.

    This Proxy support CRUD operations and sorting.

    PHP Code:
    /*

    Open Data Protocol Implementation for Ext Js 4
    Links:
        ExtJs 4 Server Proxy: http://docs.sencha.com/ext-js/4-0/source/Server.html#Ext-data-proxy-Server
        ExtJs 4 Ajax Proxy: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Ajax
        OData URI Conventions: http://www.odata.org/developers/protocols/uri-conventions
    License: GNU General Public License v3 http://www.gnu.org/copyleft/gpl.html
    Author: Oleg Dolzhansky dolzhansky@gmail.com

    Example:

    Ext.define('Customer', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'id', type: 'int', defaultValue: 0},
            {name: 'name', type: 'string'}
        ],
        idProperty: 'id'
    });

    var CustomersStore = Ext.create('Ext.data.Store', {
        model: 'Customer',
        proxy: {
            type: 'odata',
            url : '/Service.svc/Customers'
        },
        autoLoad: true
    });

    */

    Ext.define('Ext.ux.data.proxy.OData', {
        
    extend'Ext.data.proxy.Ajax',
        
    alternateClassName'Ext.ux.data.ProxyOData',
        
    alias'proxy.odata',

        
    /* Builds URL in the form Entity(Id), for example http://localhost/Service.svc/Customers(5) */
        
    buildUrl: function (request) {
            var 
    me this,
                
    operation request.operation,
                
    records operation.records || [],
                
    record records[0],
                
    url me.getUrl(request),
                
    id record record.getId() : operation.id;

            if (
    id) {
                if (
    url.match(/\/$/)) {
                    
    url url.substring(0url.length 1);
                }
                
    url url '(' id ')';
            }

            
    request.url url;

            return 
    me.callParent(arguments);
        },

        
    /* Returns a string of comma-separated fields from sortes with optional 'desc' directive */
        
    encodeSorters: function (sorters) {
            var 
    min = [],
                
    length sorters.length,
                
    0;

            for (; 
    lengthi++) {
                
    min[i] = sorters[i].property;
                if (
    sorters[i].direction.toLowerCase() == 'desc') {
                    
    min[i] += ' desc';
                }
            }

            return 
    min.join(',');
        }

    }, function () {
        
    Ext.apply(this.prototype, {
            
    actionMethods: {
                
    create'POST',
                
    read'GET',
                
    update'PUT',
                
    destroy'DELETE'
            
    },
            
    reader: {
                
    type'json',
                
    root'd'
            
    },
            
    headers: {
                
    'Accept''application/json'
            
    },
            
    pageParamundefined,
            
    startParam'$skip',
            
    limitParam'$top',
            
    sortParam'$orderby',
            
    noCachefalse
        
    });
    }); 
    Last edited by Oleg Dolzhansky; 15 Nov 2011 at 6:46 PM. Reason: Corrected namespace

Similar Threads

  1. Reading a OData feed into Ext-JS
    By pkaur in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 21 Mar 2011, 9:26 AM
  2. OData
    By mcamer in forum Sencha Touch 1.x: Discussion
    Replies: 5
    Last Post: 21 Mar 2011, 9:26 AM
  3. Refresh feed list(feed Panel) in feedviewer examples
    By adelphus in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 6 Nov 2008, 10:33 PM
  4. Updating Title text Of a Feed on Feed panel
    By adelphus in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 17 Jul 2008, 11:40 PM

Thread Participants: 11

Tags for this Thread