1. #1
    Sencha User
    Join Date
    Jun 2010
    Location
    France
    Posts
    44
    Vote Rating
    0
    Answers
    2
    ludm is on a distinguished road

      0  

    Default Unanswered: Model Convert Function not Called when Reloading Store

    Unanswered: Model Convert Function not Called when Reloading Store


    I have a model with a convert function and when I reload the store with a new xml, the normal data are updated but not the calculated field form the convert() function.

    How to update those fields ?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    Answers
    3575
    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


    That field has to get set to something even if it's a blank string.
    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
    Jun 2010
    Location
    France
    Posts
    44
    Vote Rating
    0
    Answers
    2
    ludm is on a distinguished road

      0  

    Default


    Hello, I have used a set function, but it still doesn't work :-(
    Here is my code :

    The model with the calculated field :

    Code:
    function conversion(value, record){
                           var nodes = record.raw.querySelectorAll('images image');
                            var arrayItem = [];
                            var l = nodes.length;
                            for( var i = 0; i < l; i++){
                                var node = nodes[i];
                                var nom=nodes[i].querySelectorAll('nom')
                                nom=nom[0].textContent;
                                 var legende=nodes[i].querySelectorAll('legende')
                                legende=legende[0].textContent;
                                arrayItem.push([nom,legende]);                         
                            };
                            return arrayItem;       
        }
    Ext.define('Galerie_Model', {
        requires: [
          'Ext.data.reader.Xml'  
        ],
        extend: 'Ext.data.Model',
        config: {
             fields: [
                {name: 'id', mapping: 'id', type: 'int'},
                {name: 'title', mapping: 'name', type: 'string'},  
                {name: 'imagesList', mapping : 'images',
                        convert: conversion
                }           
            ]
    the store :
    Code:
            GalerieStore= Ext.create('Ext.data.Store', {                                  
                model: 'Galerie_Model',
                autoDestroy: true,
                proxy: {
                    type: 'ajax',
                    autoLoad: false,
                    autoSync: false,
                    url: cheminXml,
                    noCache :true,
                    reader: {
                        type: 'xml',
                        record: 'galerie',
                        rootProperty: 'galeries',
                    }
                } , 
            });
    GalerieStore.getProxy().setUrl(cheminXml);
    the load function where I do the set
    Code:
    GalerieStore.load({                               
                callback: function(records, operation, success) {
                    if(success){
                        records[0].updateCalculatedFields();
                        records[0].set('imagesList','');
                        var tabImages = records[0].get('imagesList');
                        this.creerGalerie(tabImages,this.chemin);                    
                    }        
                },
                scope: this
            });

Thread Participants: 1

Tags for this Thread