1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    15
    Vote Rating
    0
    fvinson is on a distinguished road

      0  

    Default Unanswered: store Extjs and array

    Unanswered: store Extjs and array


    I work with MVC
    I have a model and a store
    Code:
    Ext.define('MetExplore.model.Annotation', {
            extend: 'Ext.data.Model',
            fields: [{name:'id',type:'string'},
            		 {name:'table',type:'string'},
            		 {name:'field',type:'string'},
            		 {name:'name',type:'string'},
            		 {name:'dbIdentifier',type:'string'},
            		 {name:'oldV',type:'string'},
            		 {name:'newV',type:'string'}
            		]
        });
    Ext.define('MetExplore.store.S_Annotation',{
    		extend : 'Ext.data.ArrayStore',
            model: 'MetExplore.model.Annotation',
            id: 'annotation'
        });
    In controller, i add data in the store when the user change
    Code:
    .....
    init: function() {
    		this.control(
    			{'gridReaction': {
    				edit:this.editChange},
    			'gridReaction button[action=ReactionChange]':{click:this.ReactionChange},
    
    
    ...	
     editChange: function(editor,e){	
        	//il faudra verifier qu'il n'y a pas deja cet enregistrement dans tableau   	
        	var oldV= e.originalValue;
        	var newV= e.value;
        	if (oldV != newV) {
        		//ajout dans tableau : id/ field / oldValue / NewValue
        		var annot= Ext.getStore('S_Annotation');
        		annot.add({'id':e.record.get('id'),'table':'Reaction','field':e.field,'name':e.record.get('name'),'dbIdentifier':e.record.get('dbIdentifier'),'oldV':oldV,'newV':newV});
        	};
    ...
    this is ok
    when the user click on button 'ReactionChange' , i want to send the data to php file in json format like this :
    [{'id':10,'table':'Reaction','field':name',.....},
    {'id':....

    In my code i send an Extjs object and i can't read it in php ; i want just the array with the data and not constructor,.....
    Code:
    			buttons : [ {
    				text : 'Submit',
    				handler : 
    					function(widget, event) {
    						var annot= Ext.getStore('S_Annotation');
    					   	//var jsonModif= Ext.encode(annot);
    					   	var jsonModif= annot.getRange();
    					   	console.log(jsonModif);
    					   	Ext.Ajax.request({
    					   		url:'lib/php/changereaction_v1.php',
    					   		params: {Reactions:jsonModif},//,idUser:idUser}
    How can i make this
    Thank you

  2. #2
    Sencha User
    Join Date
    Aug 2012
    Posts
    33
    Vote Rating
    0
    Answers
    2
    alane is on a distinguished road

      0  

    Default


    You may want to look at http://docs.sencha.com/ext-js/4-0/#!...ta.writer.Json. They have a good example of how it ties into a store at http://dev.sencha.com/deploy/ext-3.4...ful/restful.js.

Thread Participants: 1