1. #1
    Sencha User
    Join Date
    Jan 2013
    Location
    Riyadh
    Posts
    3
    Vote Rating
    0
    Anasota is on a distinguished road

      0  

    Default Answered: Multi store records inside one textarea

    Answered: Multi store records inside one textarea


    I have been testing extjs4 along with cakephp and am now stuck on putting mutil store records in one single textarea
    I have the fallowing in my .js view file
    Code:
    {         
    xtype: 'textarea', 
    name : 'notes',                      //notes will hold foreign_key number   
    allowBlank: true, 
    fieldLabel: 'Notes',    
    editable: false,       
    anchor: '100%' 
     }
    This is the .js model file. File I want to call and filter (Notes store)

    Code:
    Ext.define('Mc.model.Notes',{
    extend: 'Ext.data.Model'
     ,fields: [
    {name: 'id', type: 'int'}
    ,{name: 'foreign_key', type: 'int'}
    ,{name: 'user_id', type: 'int'}
    ,{name: 'user_name', type: 'string'}
    ,{name: 'notes', type: 'string'}
    ,{name: 'all', convert: function(v, record) {
    var note = '- '+record.get('notes');
    var username = ' ('+record.get('user_name')+')\r\n';
    return note , username;
    }}
    ]
    });
    the idea is that all records containing the same foreign_key will be shown inside the textarea. fields 'all' to be exact.

    Any suggestions please?

    Thank you

  2. Try looping the store, building a string and assign that string to the textarea.

    Code:
     
    var allText='';
    
    // Get a reference to the store and loop through it
    store.each(function(item, index, count) {     
        allText+=item.get('all'); // add \n for line breaks
    })
    
    // Get a reference to the textarea and assign the string to it
    textarea.setValue(allText);
    Good luck!

  3. #2
    Sencha Premium Member EPV's Avatar
    Join Date
    Dec 2010
    Location
    Sweden
    Posts
    175
    Answers
    23
    Vote Rating
    14
    EPV will become famous soon enough

      0  

    Default


    Try looping the store, building a string and assign that string to the textarea.

    Code:
     
    var allText='';
    
    // Get a reference to the store and loop through it
    store.each(function(item, index, count) {     
        allText+=item.get('all'); // add \n for line breaks
    })
    
    // Get a reference to the textarea and assign the string to it
    textarea.setValue(allText);
    Good luck!

Thread Participants: 1

Tags for this Thread