1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    30
    Vote Rating
    0
    pm.sreejith is on a distinguished road

      0  

    Question Store looping is not working inside the load function

    Store looping is not working inside the load function


    Hi All,

    I am trying to loop the items returned from the store. please go through the code given below it having any issues. Also I'm getting the Json response from server successfully.

    Controller
    -----------------
    Code:
    Ext.define('Sencha.controller.Main', {
        extend: 'Ext.app.Controller',
        
        stores: [
            'Mains', 'Contentlist', 'Latestarticles', 'ArticleCategoryWise'
        ], 
        
        views: ['Home', 'Products', 'Contact', 'Article','LatestArticles','ContentList', 'ContentCarousel'],
        
        refs: [
            {
                ref: 'contactForm',
                selector: '#contactForm'
            },
            {
                ref: 'contentList',
                selector: 'contentlist'        
            },
            {
                ref: 'contentCarousel',
                selector: 'contentcarousel'
            },
            {
                ref: 'articleCategoryWise',
                selector: 'ArticleCategoryWise'
            }
        ],   
        
        init: function() {
            this.control({
                'button[action=submitContact]': {
                    tap: 'submitContactForm'
                },
                'contentlist': {
                    select: this.onGetLatestArticles
                }            
            });
                    
            this.getArticles(0);
                    
        },
        
        submitContactForm: function() {
            var form = this.getContactForm();
            
            form.submit({
                url: 'contact.php'
            });
        },
        
        onGetLatestArticles: function(list,category){
            
            iCategoryId = category.get('categoryid');        
            this.getArticles(iCategoryId);
            
            /*
            var carItems = [];
            carItems.push({
                html: '<img src="http://static.icc-cricket.yahoo.net/ugc/images/DAB0CAA87C80E06A0E0279448E462AAA_1259662727486_802.jpg" alt="no image" width=395 height=600</img>',
            });                
            this.getContentCarousel().setItems(carItems);*/
        },
        
        getArticles:function(iCatId){
            
            articleCatWise = this.getArticleCategoryWiseStore();
            articleCatWise.clearFilter();
            articleCatWise.filter([{property: 'catId',value: iCatId}]);
    
            articleCatWise.load({
                scope   : this,
                callback: function(records, operation, success) {
                    
                    var arrArticleItems = [];
                    var carouselItems = [];
                    var carouselSubItems = [];                
                    var iCnt = 0;
                    
                    //the operation object contains all of the details of the load operation
                    articleCatWise.each(function(rec){
                        Ext.Msg.alert("Arr Length", "Inside Loop", function(){});
                    });
                    
                    Ext.Msg.alert("Arr Length", "After Loop", function(){});
                    
                }
            });
        }
        
    });
    Store
    -------------
    Code:
    Ext.define('Sencha.store.ArticleCategoryWise', {
        extend  : 'Ext.data.Store',
        xtype: 'ArticleCategoryWise',
        model   : 'Sencha.model.ArticleCategoryWise',
        requires: ['Sencha.model.ArticleCategoryWise'],
        
        filters: [{
            property: 'catId',
            value: 0
        }],    
        
        proxy : {
            type : 'ajax',
            url : 'getarticlescategorywise.php',
            reader : {
              type : 'json',
              root : 'articles',
              totalCount : 'total'
            }
        },
        autoLoad: true
    });
    Json Response
    ------------------------
    Code:
    
    {"success":true,"total":1,"articles":[{"articleid":12,"articletitle":"Test Title","articledate":"November 11 2011","articleshortdesc":"Test Description","articleimg":"Test Image"}]}
    I'm developing by using ST2.0 with MVC pattern.

    Any help would be appreciated....

  2. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Hi.
    Your load callback function returns you the loaded records.
    Did you try to loop on those?
    If you show an alert just before to loop the store, is it shown?
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi