1. #1
    Ext User
    Join Date
    Oct 2010
    Posts
    3
    Vote Rating
    0
    G-Force is on a distinguished road

      0  

    Default Setting Store field value from other field values at load time

    Setting Store field value from other field values at load time


    Hi all,

    I seem to recall an example that I've seen where a store field value or a grid column value was rendered by adding/subtracting two other fields at load time. I have tried all variations of search terms that I can think of but none of them has led me in the right direction so could someone please help me out?
    Something like....

    PHP Code:
    var timeStore = new Ext.data.JsonStore({
            
    url'/gettime',
            
    method'POST',
            
    fields: [
               {
    name'fromtime'type'date'dateFormat'H:i'},
               {
    name'totime'type'date'dateFormat'H:i'},
               {
    name'length'type'number'defaultValue:totime.replace(/:/,"")-fromtime.replace(/:/,"")}
            ]    
    }); 
    Thanks,

    G-Force

  2. #2
    Ext User
    Join Date
    Oct 2010
    Posts
    3
    Vote Rating
    0
    G-Force is on a distinguished road

      0  

    Default


    I got it working using the ColumnModel renderer like this:

    PHP Code:
                {header'Length',
                    
    width:50,
                    
    dataIndex:'length',
                    
    renderer: function(valuemetaDatarecordrowIndexcolIndexstore) {
                        var 
    mDiff =  (parseInt(record.get('totime').dateFormat('H'))*60+parseInt(record.get('totime').dateFormat('i'))-(parseInt(record.get('fromtime').dateFormat('H'))*60+parseInt(record.get('fromtime').dateFormat('i'));
                        var 
    sign = (mDiff<0?'-':'');
                        
    mDiff Math.abs(mDiff);
                        var 
    hDiff Math.floor(mDiff/60);
                        
    mDiff mDiff 60;
                        return 
    sign+(hDiff<10?'0':'')+hDiff+':'+(mDiff<10?'0':'')+mDiff;
                    }  
                } 
    Probably basic stuff for most and I'm sure the time subtraction can be more elegant but this does the job.

    Thanks,

    G-Force

Similar Threads

  1. setting field label and field type based on XML value
    By brikonwall in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 18 Mar 2008, 7:16 PM
  2. Let Store.load wait for results, setting (ComboBox) display values in grid
    By lvanderree in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 14 Oct 2007, 4:00 PM
  3. Setting field properties automatically on form load
    By HartlepoolLad in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 31 Jul 2007, 2:54 AM
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