1. #1
    Ext User
    Join Date
    Aug 2009
    Posts
    100
    Vote Rating
    0
    bbxx is on a distinguished road

      0  

    Default Number rounds to two decimals in Property Grid

    Number rounds to two decimals in Property Grid


    I am loading a float into a property grid field, but the default number editor is rounding to 2 decimal points. How do I remove this limitation?

    Code:
    var rec = new Ext.grid.PropertyRecord({
                                    name: fName,
                                    value: new parseFloat(fValue)
                                });

  2. #2
    Ext User
    Join Date
    Aug 2009
    Posts
    100
    Vote Rating
    0
    bbxx is on a distinguished road

      0  

    Default


    I tried to add a custom editor to my property grid now, but it's not quite working. After I try to edit a number field, I get the error from firebug:
    this.source is undefined
    [IMG]chrome://firebug/content/blank.gif[/IMG] this.source[record.id] = v;

    Then the newly entered number is not displayed. But if I click on the cell to edit again, the new number is there.

    What am I doing wrong?


    Code:
        var peoplePropsGrid = new Ext.grid.PropertyGrid({
            height: 200,
            autoScroll: true,
            customEditors: {
                'number': new Ext.grid.GridEditor(new Ext.form.NumberField({selectOnFocus:true, decimalPrecision:4, style:'text-align:left;'}))
            },
            viewConfig : {
                forceFit: true,
                scrollOffset: 19
            }
        });

  3. #3
    Ext User
    Join Date
    Aug 2009
    Posts
    100
    Vote Rating
    0
    bbxx is on a distinguished road

      0  

    Default


    I think it has something to do with the fact that I didn't use setSource. Instead I used:

    Code:
    peoplePropsGrid.getStore().addSorted(rec);

    Quote Originally Posted by bbxx View Post
    I tried to add a custom editor to my property grid now, but it's not quite working. After I try to edit a number field, I get the error from firebug:
    this.source is undefined
    [IMG]chrome://firebug/content/blank.gif[/IMG] this.source[record.id] = v;

    Then the newly entered number is not displayed. But if I click on the cell to edit again, the new number is there.

    What am I doing wrong?


    Code:
        var peoplePropsGrid = new Ext.grid.PropertyGrid({
            height: 200,
            autoScroll: true,
            customEditors: {
                'number': new Ext.grid.GridEditor(new Ext.form.NumberField({selectOnFocus:true, decimalPrecision:4, style:'text-align:left;'}))
            },
            viewConfig : {
                forceFit: true,
                scrollOffset: 19
            }
        });

  4. #4
    Ext User
    Join Date
    Aug 2009
    Posts
    100
    Vote Rating
    0
    bbxx is on a distinguished road

      0  

    Default


    I've reworked my code so that I am using setSource, and now I am not getting any errors. Here is my latest attempt:

    Code:
        myPropCM = Ext.extend(Ext.grid.PropertyColumnModel, {
                   initComponent : function(){
                        Ext.grid.EditorGridPanel.superclass.initComponent.call(this);
    
                        this.editors = {
                            'date' : new Ext.grid.GridEditor(new Ext.form.DateField({selectOnFocus:true})),
                            'string' : new Ext.grid.GridEditor(new Ext.form.TextField({selectOnFocus:true})),
                            'number' : new Ext.grid.GridEditor(new Ext.form.NumberField({selectOnFocus:true, decimalPrecision:16, style:'text-align:left;'}))
                        };
                   }
            });
    
        var peoplePropsGrid = new Ext.grid.PropertyGrid({
            height: 200,
            autoScroll: true,
            cm: new myPropCM(),
            /*
            customEditors: {
                'number': new Ext.grid.GridEditor(new Ext.form.NumberField({selectOnFocus:true, decimalPrecision:16}))
            },
            */
            viewConfig : {
                forceFit: true,
                scrollOffset: 19
            }
        });

    It's still not working though... It is rounding to 2 significant digits. Can someone point me in the right direction? Thanks

  5. #5
    Ext User
    Join Date
    Aug 2009
    Posts
    100
    Vote Rating
    0
    bbxx is on a distinguished road

      0  

    Default


    ok, I finally figured out how to do this after reading through the extjs source code. Hopefully this will help someone else if they google this problem:

    Code:
        Ext.override(Ext.grid.PropertyColumnModel, {
                getCellEditor : function(colIndex, rowIndex){
                    var p = this.store.getProperty(rowIndex),
                        n = p.data.name, 
                        val = p.data.value;
                    if(this.grid.customEditors[n]){
                        return this.grid.customEditors[n];
                    }
                    if(Ext.isDate(val)){
                        return this.editors.date;
                    }else if(typeof val == 'number'){
                        if(this.grid.customEditors['number'])
                            return this.grid.customEditors['number'];
                        else
                            return this.editors.number;
                    }else if(typeof val == 'boolean'){
                        return this.editors['boolean'];
                    }else{
                        return this.editors.string;
                    }
                }
            });
    
        var peoplePropsGrid = new Ext.grid.PropertyGrid({
            height: 200,
            autoScroll: true,
            customEditors: {
                'number': new Ext.grid.GridEditor(new Ext.form.NumberField({selectOnFocus:true, decimalPrecision:16, style:'text-align:left;'}))
            },
            viewConfig : {
                forceFit: true,
                scrollOffset: 19
            }
        });

  6. #6
    Sencha User
    Join Date
    Nov 2012
    Posts
    7
    Vote Rating
    0
    yuhanlee is on a distinguished road

      0  

    Default


    seems no one is replying to your thread. But this has helped me. Thanks alot!

Thread Participants: 1

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