Dec 30, 2010, 10:37 PM
[CLOSED] Best practive for creating custom/composite controls
Hi,
I've seen a few nice examples in ExtJs of creating custom components by extending existing ones. I'd like to do something similar with Ext.Net, but not sure where to begin. I've seen a few threads/posts but some are old now or specific such as extending trees or grids.
In my scenario, I have a border layout with:
1) The center containing some specific HTML (and asp.net/Ext.net controls) - basically an ITemplate
2) The south containing a grid
Instantiating this custom control would simply set properties to say what part of the center panel's HTML will be shown, hidden, rendered etc (or even just given a control to render). The center panel is therefore internally generated based on all these properties.
The grid panel, similarly, is internally wired up.
For now I've been doing this as a helper class that just builds the required UI, passing in all the class parameters in the constructor to the helper and/or via properties on that helper. This works quite well in my following scenarios:
- ASPX pages where the entire UI is dynamically rendered in code behind
- ASPX pages or controls where this portion of the UI is rendered dynamically inside a container
- ASHX handlers that call the same class and returns an XControl (as you helped me in a previous thread)*
- Unit testing (Nunit)
* Just for clarity, that ASHX example involves something like this in the ProcessRequest method:
The one scenario where the helper class approach doesn't work is of course if we want to declare this via markup.
So I wonder if there is a better way to do this. Inheriting borderlayout does not feel right, as what I am creating is not a layout. So should I inherit Container and internally create the border layout with the center and south regions at the right time (what is that right time? the Render method?) Or, looking at the way BorderLayout is defined, it is 4 partial classes with builders etc. Would I need to implement something similar?
This isn't super urgent, as the helper class works in many cases, but I'd be interested to know the right pattern(s) to follow in Ext.Net. If there is existing documentation, examples or forum threads already covering this, please let me know.
Thanks!
I've seen a few nice examples in ExtJs of creating custom components by extending existing ones. I'd like to do something similar with Ext.Net, but not sure where to begin. I've seen a few threads/posts but some are old now or specific such as extending trees or grids.
In my scenario, I have a border layout with:
1) The center containing some specific HTML (and asp.net/Ext.net controls) - basically an ITemplate
2) The south containing a grid
Instantiating this custom control would simply set properties to say what part of the center panel's HTML will be shown, hidden, rendered etc (or even just given a control to render). The center panel is therefore internally generated based on all these properties.
The grid panel, similarly, is internally wired up.
For now I've been doing this as a helper class that just builds the required UI, passing in all the class parameters in the constructor to the helper and/or via properties on that helper. This works quite well in my following scenarios:
- ASPX pages where the entire UI is dynamically rendered in code behind
- ASPX pages or controls where this portion of the UI is rendered dynamically inside a container
- ASHX handlers that call the same class and returns an XControl (as you helped me in a previous thread)*
- Unit testing (Nunit)
* Just for clarity, that ASHX example involves something like this in the ProcessRequest method:
new DirectResponse(BuildUI().ToScript(RenderMode.AddTo, _outputContainerId)).Return();
(Where BuildUI returns an XControl)The one scenario where the helper class approach doesn't work is of course if we want to declare this via markup.
So I wonder if there is a better way to do this. Inheriting borderlayout does not feel right, as what I am creating is not a layout. So should I inherit Container and internally create the border layout with the center and south regions at the right time (what is that right time? the Render method?) Or, looking at the way BorderLayout is defined, it is 4 partial classes with builders etc. Would I need to implement something similar?
This isn't super urgent, as the helper class works in many cases, but I'd be interested to know the right pattern(s) to follow in Ext.Net. If there is existing documentation, examples or forum threads already covering this, please let me know.
Thanks!
Last edited by Daniil; Jan 04, 2011 at 11:50 AM.
Reason: [CLOSED]