1. #1
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    11
    Vote Rating
    0
    chrwjr is on a distinguished road

      0  

    Question TPL eval expression

    TPL eval expression


    Hello:

    I need to find the minimum credit score value amongst 4 borrowers on a property mortgage. When the user clicks on the loan in the grid panel, there are tabs beneath that provide a detailed view of the loan application. I am trying to update the tpl within a fieldset for the tab as follows:

    In Ext Designer, I have:
    Representative Score: {[ Math.min(values.borr1_mid_score, values.borr2_mid_score, values.borr3_mid_score, values.borr4_mid_score) + "<br>"]}

    but that yields "0". What am I doing wrong and is there a way to do this within Designer. I know I can employ <tpl></tpl> tags in code, but that code is overwritten each time I generate my code through designer. Thank you.

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    8,892
    Vote Rating
    102
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    That looks okay. Does it always yield 0 even at runtime?

    Have you loaded legitimate data into the store at this time?
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    11
    Vote Rating
    0
    chrwjr is on a distinguished road

      0  

    Default


    Yes it yields zero at runtime. All other values are displayed appropriately. Here is an excerpt of some of the code, in which the borrower information does display when it exists (> 0.0). In my store, loaded from a php program, one or more borrowers legitimately display, but even if a borrower and their spouse have credit scores of 740 and 750, respectively, the function yields a zero at runtime. Perhaps there is a better method for conditionally populating the tpl when using designer that will not get overwritten when it generates code? If so, I would be happy to explore that option as all this coding in designer is a bit difficult to maintain anyway.
    Code:
     items: [
                                            {
                                                xtype: 'fieldset',
                                                height: 200,
                                                id: 'credit_details',
                                                itemId: 'credit_details',
                                                margin: 10,
                                                tpl: Ext.create('Ext.XTemplate', 
                                                    '<table style="border: none; ">',
                                                    '<tr>',
                                                    '<td class="uheader" colspan="2">Credit Scores</td>',
                                                    '</tr>',
                                                    '{[ values.borr1_mid_score > 0.0 ? "<tr><td class=\'label\'>" + values.borr_first_name + " " + values.borr_last_name + "</td><td class=\'lvalue\'>" + values.borr1_mid_score + "</td></tr>" : null ]}',
                                                    '{[ values.borr2_mid_score > 0.0 ? "<tr><td class=\'label\'>" + values.borr2_first_name + " " + values.borr2_last_name + "</td><td class=\'lvalue\'>" + values.borr2_mid_score + "</td></tr>" : null ]}',
                                                    '{[ values.borr3_mid_score > 0.0 ? "<tr><td class=\'label\'>" + values.borr3_first_name + " " + values.borr3_last_name + "</td><td class=\'lvalue\'>" + values.borr3_mid_score + "</td></tr>" : null ]}',
                                                    '{[ values.borr4_mid_score > 0.0 ? "<tr><td class=\'label\'>" + values.borr4_first_name + " " + values.borr4_last_name + "</td><td class=\'lvalue\'>" + values.borr4_mid_score + "</td></tr>" : null ]}',
                                                    '<tr>',
                                                    '<td class="label">',
                                                    'Representative Score:</td><td class="lvalue">{[ Math.min(values.borr1_mid_score, values.borr2_mid_score, values.borr3_mid_score, values.borr4_mid_score) + "<br>"]}',
                                                    '</td></tr></table>'
                                                ),
                                                width: 324,
                                                title: 'Credit Details'
                                            },
                                            {
                                                xtype: 'fieldset',
                                                height: 200,
                                                id: 'ratios_and_underwriting_details',
                                                itemId: 'ratios_and_underwriting_details',
                                                margin: 10,
                                                tpl: Ext.create('Ext.XTemplate', 
                                                    '<table style="border: none; ">',
                                                    '{[ values.du_findings != "" ? "<tr><td class=\'label\'>DU Findings:</td><td class=\'lvalue\'>" + values.du_findings + "</td></tr>" : null ]}',
                                                    '{[ values.lp_findings != "" ? "<tr><td class=\'label\'>LP Findings:</td><td class=\'lvalue\'>" + values.lp_findings + "</td></tr>" : null ]}',
                                                    '<tr>',
                                                    '<td class="uheader" colspan="2">Ratios</td></tr>',
                                                    '<tr>',
                                                    '<td class="label">Housing:</td><td class="lvalue">{income_ratio}</td>',
                                                    '</tr>',
                                                    '<tr>',
                                                    '<td class="label">Debt Ratio:</td><td class="lvalue">{debt_ratio}</td>',
                                                    '</tr>',
                                                    '<tr>',
                                                    '<td class="uheader" colspan="2">Appraisal Info</td>',
                                                    '</tr>',
                                                    '<tr>',
                                                    '<td class="label">Loan amount:</td><td class="lvalue">{loan_amount:usMoney}</td>',
                                                    '</tr>',
                                                    '<tr>',
                                                    '<td class="label">Appraisal Value:</td><td class="lvalue">{appraisal:usMoney}</td>',
                                                    '</tr>',
                                                    '<tr>',
                                                    '<td class="label">CLTV:</td><td class="lvalue">{tltv}</td>',
                                                    '</tr>',
                                                    '<tr>',
                                                    '<td class="label">Occupancy Intent:</td><td class="lvalue">{intent}</td>',
                                                    '</tr>',
                                                    '</table>'
                                                ),
                                                width: 324,
                                                title: 'Ratios and Underwriting Details'
                                            }
                                        ]
                                    },
    Last edited by aconran; 9 Jan 2012 at 4:58 PM. Reason: add code tags

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    8,892
    Vote Rating
    102
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    if you console.dir(values) in the template

    like so
    Code:
    '{[console.dir(values)]}'
    Are the values accurate? How are you applying the tpl's data?
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  5. #5
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    11
    Vote Rating
    0
    chrwjr is on a distinguished road

      0  

    Default


    Sorry for the delay in getting back to you.
    This is resolved. The {[console.dir(values)]} showed me the error of my ways. In a situation where there are only 2 borrowers, the credit scores of the 3rd and 4th borrower are zero. Therefore:

    {[ Math.min(values.borr1_mid_score, values.borr2_mid_score, values.borr3_mid_score, values.borr4_mid_score) ]}

    was giving me the minimum of 765, 748, 0 and 0 Duh!

    I will need to come up with a better way to condition this.

  6. #6
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    11
    Vote Rating
    0
    chrwjr is on a distinguished road

      0  

    Default


    So I would like to pursue a more maintainable way to set the tpl and pass that into the view/ui. How would I go about it?

    For example:

    in view:

    initComponent: function() {
    var me = this;
    me.callParent(arguments);
    var sm = me.down('#loan_grid').getSelectionModel();
    sm.on('select', me.onGridRowSelect, me);
    },


    onGridRowSelect: function(grid, record) {

    if(record.data.borr2_mid_score > 0) {
    ... etc ...
    [set tpl to some value]

    Then in the view/ui:

    instead of creating and setting the tpl -


    items: [
    {
    xtype: 'fieldset',
    height: 200,
    id: 'credit_details',
    itemId: 'credit_details',
    margin: 10,
    tpl: Ext.create('Ext.XTemplate',
    '<table style="border: none; ">',
    '<tr>',
    '<td class="uheader" colspan="2">Credit Scores</td>',
    '</tr>',
    '{[ values.borr1_mid_score > 0.0 ? "<tr><td class=\'label\'>" + values.borr_first_name + " " + values.borr_last_name + "</td><td class=\'lvalue\'>" + values.borr1_mid_score + "</td></tr>" : null ]}',
    '{[ values.borr2_mid_score > 0.0 ? "<tr><td class=\'label\'>" + values.borr2_first_name + " " + values.borr2_last_name + "</td><td class=\'lvalue\'>" + values.borr2_mid_score + "</td></tr>" : null ]}',
    '{[ values.borr3_mid_score > 0.0 ? "<tr><td class=\'label\'>" + values.borr3_first_name + " " + values.borr3_last_name + "</td><td class=\'lvalue\'>" + values.borr3_mid_score + "</td></tr>" : null ]}',
    '{[ values.borr4_mid_score > 0.0 ? "<tr><td class=\'label\'>" + values.borr4_first_name + " " + values.borr4_last_name + "</td><td class=\'lvalue\'>" + values.borr4_mid_score + "</td></tr>" : null ]}',
    '<tr>',
    '<td class="label">',
    'Representative Score:</td><td class="lvalue">{[ Math.min(values.borr1_mid_score, values.borr2_mid_score, values.borr3_mid_score, values.borr4_mid_score) + "<br>"]}',
    '</td></tr></table> .....

    create it and pass the tpl created above. Then the code would be easier to maintain.


    '

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar