-
26 Jul 2011 8:50 AM #1
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?Roland Schütz
Senior Software Architect
---
Bancha Project - Seamless integrate CakePHP with ExtJS and Sencha Touch
-
15 Sep 2011 8:49 PM #2
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.
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' }.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"); } }
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?
-
22 Sep 2011 9:12 AM #3
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
RolandRoland Schütz
Senior Software Architect
---
Bancha Project - Seamless integrate CakePHP with ExtJS and Sencha Touch


Reply With Quote