1. #1
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    564
    Vote Rating
    8
    Dumas is on a distinguished road

      0  

    Default Working on a new Grid and Form Scaffold Library - Desgin Questions

    Working on a new Grid and Form Scaffold Library - Desgin Questions


    Hi!

    For my current project I'm working on a (open-source) scaffold class. My first idea was a straigt forwand factory pattern, but tanks to mberrie I had some new ideas. My current solution of how it could look like is this:

    Code:
    // very simple, will scaffold everything from model data and scaffold defaults
    Ext.create("Ext.grid.Panel", {
        scaffold: 'User' // model name
    }); 
    
    
    // multiple configs
    Ext.create("Ext.grid.Panel", {
        scaffold: 'User,
    
        // basic scaffold configs can be set directly
        enableCreate : true,
        enableUpdate : true,
        enableReset  : true,
        enableDestroy: true,
    
        // advanced configs can be set here:
        scaffoldConfig: {
            columnDefaults: {
                width: 200
            },
            datecolumnDefaults: {
                format: 'm/d/Y'
            },
            // use the same store for all grids
            oneStorePerModel: true,
            // custom onSave function
            onSave: function() {
                Ext.MessageBox.alert("Tada","You've pressed the save button");
            }
        }
    
        // and add some styling
        height   : 350,
        width    : 650,
        frame    : true,
        title    : 'User Grid',
        renderTo : 'gridpanel'
    });

    What do you think of this?

  2. #2
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    507
    Vote Rating
    14
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    Sorry I didn't come back to you. Sometimes I lose track of my forum activities

    This approach looks very neat IMHO. Kind of like Grails, isn't it?

    You could even trim it down further. There is not really a need to separate the config into two properties.


    Code:
    // multiple configs
    Ext.create("Ext.grid.Panel", {
        // advanced configs can be set here:
        scaffold: {
            target: 'user',
    
            columnDefaults: {
                width: 200
            },
            datecolumnDefaults: {
                format: 'm/d/Y'
            },
            // use the same store for all grids
            oneStorePerModel: true,
            // custom onSave function
            onSave: function() {
                Ext.MessageBox.alert("Tada","You've pressed the save button");
            }
        }
    Both Extjs and Grails actually do that a lot (e.g. proxy can be just the type - 'ajax' - or a config object like { type: 'ajax', url: 'xxx' }.
    It is something that works very nicely in a not-strongly-typed language like JavaScript.

    However, I would define function callbacks on the object itself, not inside the config object. Your code can easily check if there is an onSave function on the object and trigger it, or otherwise do nothing or call a default implementation.



    Did you find the time to work on your project?

  3. #3
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    564
    Vote Rating
    8
    Dumas is on a distinguished road

      0  

    Default


    Hi!

    The idea with scaffold: { target: 'user' } is good.

    I did purposely set the callback on the config, there are already other plugins which use e.g. the objects onSave function, so I don't want a confusion here.

    I already worked in it, the js is already finish, we just have a view issues with cake in the backend... hoping to release it soon.

    best regards
    Roland

Thread Participants: 1

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