Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    9
    Vote Rating
    0
    lcuff is on a distinguished road

      0  

    Default Answered: How to invoke a renderer on a displayfield xtype

    Answered: How to invoke a renderer on a displayfield xtype


    I'm new to ExtJS and, working in a team environment where someone else wrote the code I'm trying to modify, I find myself wanting to call the currency formatter ( Ext.util.Format.currency(value, '$ ', 2) on a value that's in a displayfield, but as far as I can see, it isn't valid to do so. displayfield doesn't support the 'renderer:' configuration item.

    Is this a simple matter of changing the xtype to some other type? I see that if I completely re-architected my code I might be able to put the data into a gridpanel, which supports a renderer, but the data really isn't suited to a gridpanel.

    Am I missing something simple?

    Thanks in advance for any and all help.

  2. I think all you need to do is override the valueToRaw function for the components you want. If you're going to re-use the component, then you'll probably want to create a simple subclass. Here's an example:

    Code:
    Ext.define('CurrencyField', {
        extend: 'Ext.form.field.Display',
        alias: ['widget.currencyfield'],
        
        valueToRaw: function(value) {
            return Ext.util.Format.currency(value, '$ ', 2);
        }
    });
    
    Ext.onReady(function(){
        Ext.create('Ext.form.Panel', {
            renderTo: Ext.getBody(),
            width: 175,
            height: 120,
            bodyPadding: 10,
            title: 'Money',
            items: [{
                xtype: 'currencyfield',
                fieldLabel: 'Me',
                value: 10
            }, {
                xtype: 'currencyfield',
                fieldLabel: 'You',
                value: 11.5
            }]
        });
    });

  3. #2
    Ext JS Premium Member burnnat's Avatar
    Join Date
    Jun 2011
    Posts
    414
    Answers
    41
    Vote Rating
    60
    burnnat is a jewel in the rough burnnat is a jewel in the rough burnnat is a jewel in the rough burnnat is a jewel in the rough

      1  

    Default


    I think all you need to do is override the valueToRaw function for the components you want. If you're going to re-use the component, then you'll probably want to create a simple subclass. Here's an example:

    Code:
    Ext.define('CurrencyField', {
        extend: 'Ext.form.field.Display',
        alias: ['widget.currencyfield'],
        
        valueToRaw: function(value) {
            return Ext.util.Format.currency(value, '$ ', 2);
        }
    });
    
    Ext.onReady(function(){
        Ext.create('Ext.form.Panel', {
            renderTo: Ext.getBody(),
            width: 175,
            height: 120,
            bodyPadding: 10,
            title: 'Money',
            items: [{
                xtype: 'currencyfield',
                fieldLabel: 'Me',
                value: 10
            }, {
                xtype: 'currencyfield',
                fieldLabel: 'You',
                value: 11.5
            }]
        });
    });

  4. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    9
    Vote Rating
    0
    lcuff is on a distinguished road

      0  

    Default Thanks!

    Thanks!


    This works just like I need. Thank you so much.

  5. #4
    Ext JS Premium Member burnnat's Avatar
    Join Date
    Jun 2011
    Posts
    414
    Answers
    41
    Vote Rating
    60
    burnnat is a jewel in the rough burnnat is a jewel in the rough burnnat is a jewel in the rough burnnat is a jewel in the rough

      0  

    Default


    You're welcome!

    By the way, you should be able to mark this thread as "Answered" so it doesn't show display as "Unanswered" in the forum listing anymore.

  6. #5
    Sencha User
    Join Date
    Aug 2010
    Location
    Sweden
    Posts
    13
    Vote Rating
    0
    uncoloured is on a distinguished road

      0  

    Default


    Hey guys, I hope you don't mind me borrowing this thread for a follow-up question.

    I needed to implement something similar and got it working thanks to your suggestion, burnnat. However, now that I've done all I can to follow the new MVC-pattern in Ext JS 4 it just don't feel right to paste this Ext.define-code above some other component, in the "wrong" file. How do I implement a custom view/component in the MVC-logic and filestructure?

    I've put the Ext-define-part of my component in it's own file, but from there I'm lost. I've tried putting 'MyApp.custom.MyField' in the Ext.require of my "main" app.js, but that causes the app not to start. I've tried putting the same in the require-property of a panel, with the same result. It seems the application never reaches it's launch-function when I require my new component (which loads, seemingly, with no error).

    What do I have to do? Is there anything I need to do within the definition of the new component?

Thread Participants: 2

Tags for this Thread