-
29 Jul 2010 5:55 AM #11
Also, if you are passing the same arguments through to your function, then you don't need to wrap it in an anon function.
So this...
Could be simply...PHP Code:rowcontextmenu: function(thisGrid, rowIndex, evtObj){
doRowCtxMenu(thisGrid, rowIndex, evtObj);
}
PHP Code:rowcontextmenu: doRowCtxMenu
-Shea
My Blog:VinylFox | Twitter:@VinylFox | JavaScript Magazine:JSMag | Curator of the Baltimore/DC JavaScript Meetup | Author: Learning ExtJS 3.x Book
ExtJS Extensions & Plugins: GMapPanel UX | HtmlEditor Buttons Plugin | Selection Enabler Plugin | Grid DataDrop Plugin | Additional Ext.Fx
Sencha Touch Plugins: Swipe Tabs | List Pull Refresh | Accelerometer Tabs
-
29 Jul 2010 6:01 AM #12
The following example might help you understand this concept.
http://github.com/VinylFox/JSConf/bl.../2010/app-a.js
Check out line 47, which calls a function on line 76-Shea
My Blog:VinylFox | Twitter:@VinylFox | JavaScript Magazine:JSMag | Curator of the Baltimore/DC JavaScript Meetup | Author: Learning ExtJS 3.x Book
ExtJS Extensions & Plugins: GMapPanel UX | HtmlEditor Buttons Plugin | Selection Enabler Plugin | Grid DataDrop Plugin | Additional Ext.Fx
Sencha Touch Plugins: Swipe Tabs | List Pull Refresh | Accelerometer Tabs
-
29 Jul 2010 6:05 AM #13
Well its a bit of an overhead I guess but each area that I have made is mostly self contained. They only require information from ExtJS library and from the GLOBAL functions that I have made. I could probably if given time thin out all of my areas to use generic functions but as it stands right now each area has alot of the same code. So i can just pull them out without breaking anything else.
For any grids I add they would have their own context menu handler and not a shared one.
each grid I use is wrapped in a format such as
Code:var myFn1 = function(){ var self = new Object; self.getDisplayItem = function(argCnfg){return createGP(argCnfg)}; function createGP(argCnfg){ // Create a new configuration object of a grid panel for displaying information return { // Set the ID to this grid panel id:argCnfg.id, // Set the title to this grid panel title: argCnfg.title, // Set the datastore to this grid panel ds: argCnfg.dataStore, xtype:'grid', ... listeners:{ // prevent right clicking menus contextmenu: function(evtObj){ evtObj.stopEvent(); }, // custom right clicking menus rowcontextmenu: function(thisGrid, rowIndex, evtObj){ // todo check to see if the user is an admin if(3 == 3){ doRowCtxMenu(thisGrid, rowIndex, evtObj); } }, // rowselect rowdblclick: function(argGrid, rowIndex, e) { GLOBAL_EXTJS.popupUrl({url:argGrid.getStore().getAt(rowIndex).data.productURL, winName:'ptsWin', options:'width=800,height=600,top=65,left=65,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes,location=yes'}); }, // once the panel is displayed call to get the store loaded show: function(argGrid){ this.doLayout(); // Call to load the data store only load the store if it is empty if(this.getStore().getCount() == 0){ refreshGrid(argGrid); } // if } } //listeners }; } return self; };
-
29 Jul 2010 6:10 AM #14
-
29 Jul 2010 6:20 AM #15
It always applies, you just need to think a little further ahead. Your code structure does not lend itself to being extended or programatically modified, it will just end up being a huge copy & paste festival.
-Shea
My Blog:VinylFox | Twitter:@VinylFox | JavaScript Magazine:JSMag | Curator of the Baltimore/DC JavaScript Meetup | Author: Learning ExtJS 3.x Book
ExtJS Extensions & Plugins: GMapPanel UX | HtmlEditor Buttons Plugin | Selection Enabler Plugin | Grid DataDrop Plugin | Additional Ext.Fx
Sencha Touch Plugins: Swipe Tabs | List Pull Refresh | Accelerometer Tabs
-
29 Jul 2010 6:32 AM #16
That's a weird construct.
If you really want some single function object, then create a constructor for it:
But I don't think that's what you want. It's what you ended up with.Code:MyFn = Ext.extend(Object, { getDisplayItem: createGP(argCnfg){ // Create a new configuration object of a grid panel for displaying information return { // Set the ID to this grid panel id:argCnfg.id, // Set the title to this grid panel title: argCnfg.title, // Set the datastore to this grid panel ds: argCnfg.dataStore, xtype:'grid', ... listeners:{ // prevent right clicking menus contextmenu: function(evtObj){ evtObj.stopEvent(); }, // custom right clicking menus rowcontextmenu: function(thisGrid, rowIndex, evtObj){ // todo check to see if the user is an admin if(3 == 3){ doRowCtxMenu(thisGrid, rowIndex, evtObj); } }, // rowselect rowdblclick: function(argGrid, rowIndex, e) { GLOBAL_EXTJS.popupUrl({url:argGrid.getStore().getAt(rowIndex).data.productURL, winName:'ptsWin', options:'width=800,height=600,top=65,left=65,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes,location=yes'}); }, // once the panel is displayed call to get the store loaded show: function(argGrid){ this.doLayout(); // Call to load the data store only load the store if it is empty if(this.getStore().getCount() == 0){ refreshGrid(argGrid); } // if } } //listeners }; } });
Maybe you in fact want a GridPanel subclass with some extra functions.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
29 Jul 2010 8:39 AM #17
I have no doubt that both of you are correct. I have been meaning to look into the whole extend and other features i have seen people implementing in their code I just have not had time.
Background of this app.
1. None of the developers had a clue what we were doing with ExtJS
2. Told to get the desktop example up and running with some customized links etc ASAP.
3. Instead of giving us time to actually read and figure out what were doing with this library we have been just making things work.
4. Just recently bought book ExtJS in Action so far very good but left off at around pg 180 due to being pulled off onto other tasks, deadlines and family health issues.
5. So much code was built up to make things work that the unfortunate path ahead is to at some point go back and restructure section by section, which lends to the copy and paste. This will allow us to drastically change sections without affecting other areas until we have time to address them.
I am assuming that the book I purchased will also address Extend and other features I SHOULD know of to help with the development.
-
29 Jul 2010 8:42 AM #18
-Shea
My Blog:VinylFox | Twitter:@VinylFox | JavaScript Magazine:JSMag | Curator of the Baltimore/DC JavaScript Meetup | Author: Learning ExtJS 3.x Book
ExtJS Extensions & Plugins: GMapPanel UX | HtmlEditor Buttons Plugin | Selection Enabler Plugin | Grid DataDrop Plugin | Additional Ext.Fx
Sencha Touch Plugins: Swipe Tabs | List Pull Refresh | Accelerometer Tabs
Similar Threads
-
[2.0.1]fireEvent('click') on buttons don't call handler function
By kimu in forum Ext 2.x: Help & DiscussionReplies: 10Last Post: 25 May 2012, 8:01 AM -
[SOLVED] this.handler.call is not a function
By iceburg in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 5 Jul 2008, 10:06 AM -
Handler problem : this.handler.call is not a function
By niopi in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 13 May 2008, 5:04 AM -
dialog and this.handler.call is not a function
By TopKatz in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 10 Apr 2007, 7:10 AM




Reply With Quote