1. #11
    Sencha User
    Join Date
    Feb 2013
    Posts
    1
    Vote Rating
    0
    PetrSnobelt is on a distinguished road

      0  

    Default


    Thank you for wonderfull extension!

    Is there any way how to use it with grid filters (http://docs.sencha.com/ext-js/4-0/#!...ter-local.html)

    Thank you

  2. #12
    Sencha User
    Join Date
    Jan 2013
    Posts
    7
    Vote Rating
    0
    sbk099 is on a distinguished road

      0  

    Default


    • [COLOR=red !important][/COLOR]Goodwork maiconschelter. I am pretty new to ExtJS. I want to consume OData service using your extension but getting the following error. I am using ExtJS 4.2.0.
    • ​Thanx in advance
    • [COLOR=red !important]OData.js: 69 Uncaught TypeError: Cannot read property 'remoteSort' of undefined[/COLOR]
    [FONT=Consolas, 'Lucida Console', monospace]
    [/FONT]

  3. #13
    Sencha User
    Join Date
    Sep 2013
    Location
    New York City
    Posts
    1
    Vote Rating
    0
    prgtrdr is on a distinguished road

      0  

    Default


    Hi Maiconschelter,

    Thanks very much for writing this. I think you are still the only one who has implemented OData with ExtJS. I have 3 questions:
    1. On line 52 of your code you call
      Code:
      url = Ext.util.Format.urlODataFormat(id);
      but you don't define that routine in your code and it's not part of Ext.util.Format either. Was it accidentally left out?
    2. Can you please submit some test html to show how to use your OData proxy?
    3. In the brief example you showed, what is the meaning of
      Code:
      ,params : { type : 'DTE.Model.Cars' } 
      ?

    Thanks,
    Bill

  4. #14
    Sencha User
    Join Date
    Sep 2011
    Posts
    564
    Vote Rating
    66
    ettavolt is just really nice ettavolt is just really nice ettavolt is just really nice ettavolt is just really nice

      0  

    Default


    Proxy for 4.2:
    Code:
    Ext.define('App.ODataProxy', {
        extend:'Ext.data.proxy.Ajax',
        requires:[
            'Ext.data.reader.Json',
            'Ext.data.writer.Json'
        ],
        alias:'proxy.odata',
        sortParam:'$orderby',
        filterParam:'$filter',
        pageParam:null,
        limitParam:'$top',
        startParam:'$skip',
        actionMethods: {
            create:'POST',
            read:'GET',
            //Changed from PUT to allow writer to not writeAllFields.
            update: Ext.isIE8m ? 'PUT' : 'PATCH',
            destroy:'DELETE'
        },
        headers:{
            Accept:'application/json;odata=verbose',
            Prefer:'return-content'
        },
        constructor:function(cfg) {
            cfg.reader = {
                type:'json',
                readRecords:function(data) {
                    if (data.status == 204) {
                        return null;
                    }
                    return this.self.prototype.readRecords.call(this, data['d']);
                },
                buildExtractors:function() {
                    this.self.prototype.buildExtractors.apply(this, arguments);
                    this.getRoot = this.getRootFunc;
                },
                getRootFunc:function(root) {
                    return root['results'] || [root];
                },
                totalProperty:'__count',
                metaProperty:'__metadata'
            };
            cfg.writer = {
                type:'json',
                writeAllFields:Ext.isIE8m
            };
            cfg.extraParams = Ext.apply({
                "$inlinecount":'allpages'
            },cfg.extraParams);
            return this.callParent(arguments);
        },
        buildUrl:function(request) {
            var me        = this,
                operation = request.operation,
                records   = operation.records || [],
                record    = records[0],
                url       = me.url,
                id        = record ? record.getId() : operation.id;
    
            if (id) {
                url = url.replace(/\/?$/,'(' + id + ')');
            }
            if (request.url) {
                url += request.url;
            }
            request.url = url;
            return me.callParent(arguments);
        },
        encodeSorters:function(sorters) {
            var sch, buf = [],
                sorter;
            for (sch = 0; sorter = sorters[sch]; sch++) {
                buf.push(sorter.property + ' ' + sorter.direction.toLowerCase());
            }
            return buf.join(',');
        },
        encodeFilters:function(filters) {
            var sch,
                filterChecks = [],
                filterBuf,
                filter,
                exact;
            for (sch = 0; filter = filters[sch]; sch++) {
                exact = filter.exactMatch;
                filterBuf = [];
                if (filter.exactMatch) {
                    filterBuf.push('(');
                    filterBuf.push(filter.value);
                    filterBuf.push(' eq ');
                } else {
                    filterBuf.push('substringof(\'');
                    filterBuf.push(filter.caseSensitive ? filter.value : filter.value.toLowerCase());
                    filterBuf.push('\',');
                }
                if (!filter.caseSensitive && !exact) {
                    filterBuf.push('tolower(');
                }
                filterBuf.push(filter.property);
                if (!filter.caseSensitive && !exact) {
                    filterBuf.push(')');
                }
                filterBuf.push(')');
                filterChecks.push(filterBuf.join(''));
            }
            return filterChecks.join(' and ');
        }
    });
    This doesn't work with filters ux, because I don't know how does it pass gt or lt values.

  5. #15
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,181
    Vote Rating
    77
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    Quote Originally Posted by ettavolt View Post
    Proxy for 4.2:
    This doesn't work with filters ux, because I don't know how does it pass gt or lt values.
    Hi ettavolt.

    Is this proxy "stand alone" or needs all the overrides the original poster did?

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 MVC
    Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
    Application Server: Glassfish 3.1.x
    Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5

    If you like my answer please vote!

  6. #16
    Sencha Premium Member
    Join Date
    Nov 2012
    Posts
    1
    Vote Rating
    0
    jcart is on a distinguished road

      0  

    Default our approach to extjs and odata

    our approach to extjs and odata


    We have taken a slightly different approach to integrating extjs and odata. First, we use Jaydata and odata with sencha. secondly we have modified a proxy found on the jaydata website that was written for sencha touch.

    here is our proxy:

    (function ($data, Ext)
    {
    var decimalType = $data.Container.getType('Edm.Decimal')
    $data.Container.mapType(decimalType, $data.String);

    $data.Entity.buildExtFields = function (type, config)
    {
    if (!type.isAssignableTo)
    return [];

    var fields = type.memberDefinitions.getPublicMappedProperties().map(function (memDef) { return memDef.name; });

    if (config instanceof $data.Array)
    {
    config.forEach(function (fieldConfig)
    {
    if (typeof fieldConfig === 'object' && fieldConfig.name)
    {
    var fieldIndex = fields.indexOf(fieldConfig.name);
    if (fieldIndex >= 0)
    {
    fields[fieldIndex] = fieldConfig;
    } else
    {
    fields.push(fieldConfig);
    }
    }
    });
    }
    return fields;
    }

    Ext.define('Ext.data.proxy.JayData', {
    extend: 'Ext.data.proxy.Server',

    alias: 'proxy.JayData',
    alternateClassName: ['Ext.data.JayData'],

    config: {
    queryable: null,
    withInlineCount: true,
    modelType: null,
    includeProperties:[]
    },

    map: null,

    //read: function () {
    // return this.doRequest.apply(this, arguments);
    //},

    create: function (operation, callback, batch) {
    var me = this;
    Ext.Array.forEach(operation.records,
    function (rec) {
    if (Ext.isFunction(rec.asQueryable))
    me.queryable.add(rec.asQueryable());
    else
    me.queryable.add(rec.raw);
    });
    if (!operation.config || !operation.config.batch)
    {
    me.queryable.saveChanges({
    success: function () {
    if(operation && operation.success)
    operation.success(arguments);
    }, error: function () {
    if (operation && operation.failure)
    operation.failure(arguments);
    }
    })

    }

    },

    update: function (operation, callback, batch) {
    var me = this;

    Ext.Array.forEach(operation.records,
    function (rec) {
    if (Ext.isFunction(rec.asQueryable) && Ext.isFunction(rec.asRawQueryable))
    Ext.apply(me.queryable.attachOrGet(rec.asRawQueryable()), rec.asQueryable());
    else
    Ext.apply(me.queryable.attachOrGet(rec.raw), rec.data);
    });

    if (!operation.config || !operation.config.batch) {
    me.queryable.saveChanges({
    success: function () {
    if (operation && operation.success)
    operation.success(arguments);
    }, error: function () {
    if (operation && operation.failure)
    operation.failure(arguments);
    }
    })

    }
    },

    destroy: function (operation, callback, batch) {
    var me = this;

    Ext.Array.forEach(operation.records,
    function (rec) {
    if (Ext.isFunction(rec.asQueryable))
    me.queryable.remove(rec.asQueryable());
    else
    me.queryable.remove(rec.raw);
    });

    if (!operation.config || !operation.config.batch) {
    me.queryable.saveChanges({
    success: function () {
    if (operation && operation.success)
    operation.success(arguments);
    }, error: function () {
    if (operation && operation.failure)
    operation.failure(arguments);
    }
    })

    }
    else {
    callback(operation);
    }
    },

    onBatchComplete: function(batchOptions, batch) {
    var me = this;

    me.queryable.saveChanges(batchOptions);
    },
    removeRange: function(index,count){

    },

    doRequest: function (operation, callback, scope)
    {
    var me = this,
    request = this.buildRequest(operation);

    if (!me.queryable)
    me.processResponse(false, operation, request, null, callback, scope);

    if (operation.action == 'read')
    return me.doRead(request, operation, callback, scope);


    return request;
    },
    saveChanges:function(context, callbacks)
    {
    context.saveChanges(callbacks);
    },
    buildRequest: function (operation)
    {
    var me = this,
    params = Ext.applyIf(operation.config || {}),
    request;

    //copy any sorters, filters etc into the params so they can be sent over the wire
    params = Ext.applyIf(params, operation.config);

    request = Ext.create('Ext.data.Request', {
    params: params,
    action: operation.action,
    records: operation.getRecords(),
    operation: operation,
    proxy: me
    });

    //operation.setRequest(request);

    return request;
    },


    doRead: function (request, operation, callback, scope)
    {
    var me = this;
    var queryable = me.buildQueryable(operation, me.queryable);

    queryable.toArray({
    success: function (response)
    {

    me.processResponse(true, operation, request, response, callback, scope);
    },
    error: function (response)
    {
    if (response.data[0].response.statusCode == 401 || response.data[0].response.statusCode == 403) {

    return;
    }
    me.processResponse(false, operation, request, response, callback, scope);
    }
    });

    return request;
    },

    buildQueryable: function (operation, queryable)
    {
    var me = this;
    if (!queryable)
    return queryable;

    queryable.entityContext.prepareRequest = function (cfg)
    {
    //add any custom configuration here for data context stuff like custom headers
    }

    if (me.config && me.config.includeProperties) {
    for (var include in me.config.includeProperties) {
    queryable.include(include);
    }
    }

    var filters = operation.filters;
    if (filters)
    {
    filters.forEach(function (filter)
    {
    var operator = filter.operator || '==';
    operator = operator == '=' ? '==' : operator;
    if (filter.config.hasOwnProperty('scope') || (filter.property == undefined && filter.filterFn != undefined))
    queryable = queryable.filter(filter.filterFn, filter.scope);
    else if (filter.property && filter.value) {
    if (me.config && me.config.modelType) {
    var property = filter.property;
    for (var f in me.config.modelType.prototype.fields.items) {
    var field = me.config.modelType.prototype.fields.items[f];

    if (field.name == property) {
    property = field.mapping || property;
    break;
    }
    }
    queryable = queryable.filter('it.' + property + ' ' + operator + ' this.value', { value: filter.value });
    }
    else {
    queryable = queryable.filter('it.' + filter.property + ' ' + operator + ' this.value', { value: filter.value });
    }
    }
    });
    }


    var sorters = operation.sorters;
    if (sorters)
    {

    sorters.forEach(function (sorter)
    {
    var direction = sorter.direction === 'ASC' ? queryable.orderBy : queryable.orderByDescending;
    if (sorter.sorterFn) {
    queryable = direction.call(queryable, sorter.sorterFn);
    } else {
    if (me.config && me.config.modelType) {
    var property = sorter.property;
    for (var f in me.config.modelType.prototype.fields.items) {
    var field = me.config.modelType.prototype.fields.items[f];

    if (field.name == property) {
    property = field.mapping || property;
    break;
    }
    }
    queryable = direction.call(queryable, 'it.' + property);
    }
    else {
    queryable = direction.call(queryable, 'it.' + sorter.property);
    }
    }

    });
    }

    if (this.map)
    {
    queryable = queryable.map.call(queryable, this.map);
    }
    if (this.config.withInlineCount) {
    queryable = queryable.withInlineCount();
    console.log("inline count included in query")
    }

    var pageNum = operation.page;
    var pageLimit = operation.limit;
    if (pageNum > 1)
    queryable = queryable.skip((pageNum - 1) * pageLimit);

    queryable = queryable.take(pageLimit);

    return queryable;
    },
    constructor: function (cfg) {
    this.callParent(arguments);

    }

    });

    })($data, Ext);


    We create stores with memoryproxies and then use the processConfig to change it to use our proxy like:

    config = Ext.apply(Ext.create("Ext.data.proxy.JayData"), {
    queryable : Name.Of.Your.context.Entity
    });
    return config;

    This works well for us and only adds the requirement that we use jaydata. We also handle projections using mapping in the configuration and if a sencha model's property name doesn't match the odata entity's property, we use the map in the model to dynamically correct our query to odata with the proper field name. We can handle any of the basic query operators ( ie lt,gt,gte,lte,eq,neq). It also handles paging or the buffered stores stuff using take and skip.

    so it is a little heavier than some approaches, but it is still pretty good.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar