title: Put the knife down and take a green herb, dude. |
descrip: One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com Using 89% of the same design the blog had in 2001. |
FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white. As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green. |
|
Wednesday, September 26, 2012 | |
Surprisingly little about this on the web, at least from where I'm sitting. I want to create reusable panels in ExtJS, and the inherited code for the project I'm coding doesn't quite understand how it's done. Instead of extending ExtJS components, like the Panel, it creates generic object types that wrap around the components instead. So you have to run myObj.myPanel to get to Panels rather than just myCustomPanel. Weird. I have ExtJS in Action by Jesus "Jay" Garcia, which is pretty good, but his extension example skips past the simplest case for some reason and dives right in to a filled out example. And the extension example is a singleton. He doesn't really extend a type and instantiate several times until he's going 55 into plugin creation. Anyhow, here's some code. Just a half baby step past the trivial implementation, so that we can play around a little. PnlCustom = Ext.extend(Ext.Panel,
{
title: "Title",
html: "spam",
initComponent : function(){
PnlCustom.superclass.initComponent.call(this);
if (null == this.someVal) {
this.someVal = "NOTHING";
}
console.log("#" + this.someVal + "#");
}
});
Ext.onReady(function() {
var pnlCustom = new PnlCustom({
someVal: "3"
});
var pnlCustom2 = new PnlCustom({});
var pnlPlain = new Ext.Panel({
title: "TITLE",
items: [
pnlCustom,
pnlCustom2
],
renderTo: "uiHook"
});
//Ext.Msg.alert("test","test"); // compulsory test that Ext is set up correctly.
});
The only other thing you might want to consider is if you want to throw extra "procedural" code into initComponent or the constructor function. There's plenty on the web to help you with that, including some stuff on StackOverflow with one comment that refers to text from one Jay Garcia's books. For now, initComponent is fine.
Also remember that I was looking for an ExtJS 2.2 simplest case. There is some decent (not great, afaict) stuff on 3+. EDIT: Man, complicated. You can't use your typical Swing/Windows.Forms mental model when building ExtJS UI elements. The items collection can't be accessed inside of a definition of an extended object. Check out this thread (Jay's & Condor's answers are quite useful) to see how what you're apparently really doing is defining a prototype, not a class, per se. Labels: code, ExtJS, javascript posted by ruffin at 9/26/2012 11:55:00 AM |
|
| |
MarkUpDown is the best Markdown editor for professionals on Windows 10. It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support. Features you won't find anywhere else include...
You've wasted more than $15 of your time looking for a great Markdown editor. Stop looking. MarkUpDown is the app you're looking for. Learn more or head over to the 'Store now! |
![]() |
|
|