-
26 Sep 2008 6:17 AM #1
Extend a own class, how to have own property?
Extend a own class, how to have own property?
if i extend a own class like this
how to add my own property so that i can instant like thisCode:OwnClass = function(){ ....... } Ext.extend(OwnClass, Ext.someclass)
Code:new OwnClass({MyProperty1:property1,MyProperty2:property2})
-
26 Sep 2008 6:18 AM #2
Code:Foo = Ext.extend(Bar, { prop1: 'foo', prop2: 'bar', //others } );Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
26 Sep 2008 11:42 PM #3
i have tried this,but i can't set the value of the properties,
this is my code:
when "panel.mystr" is alerted,it's still "string_1",haven't changed to the given "string_2"Code:MyPanel = function(){ MyPanel.superclass.constructor.call(this, { title: "ddd", height: 400, width:500 }); } Ext.extend(MyPanel, Ext.Panel, { mystr : "string_1" } ); Ext.onReady(function() { panel = new MyPanel({mystr : "string_2"}); alert(panel.mystr); panel.render("my-div"); } );
-
26 Sep 2008 11:46 PM #4
found the problem
the given properties should be applied before use
so the code should be:
Code:MyPanel = function(config){ Ext.apply(this, config); MyPanel.superclass.constructor.call(this, { title: "ddd", height: 400, width:500 }); } Ext.extend(MyPanel, Ext.Panel, { mystr : "string_1" } ); Ext.onReady(function() { panel = new MyPanel({mystr : "string_2"}); alert(panel.mystr); panel.render("my-div"); } );
-
27 Sep 2008 7:51 AM #5
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow


Reply With Quote