|
Rank: Member Groups: Member
Joined: 4/1/2010 Posts: 18
|
I'm working on some custom columns I'd like to build as standalone web controls. For example I crafted a special column, from a composition of elements, suitable for currency values. I'd just like to reuse it without duplication of code and added complexity. Is it possible to extend your controls? I mean is it a possible approach to extend a MaskedEditColumn, for example, and then always use my own crafted column inside the usual <eo:Grid> ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
There is no simple ways to extend column types because the Grid needs to be aware of the column types both on the server side and client side. If you re-use the same column set often, the best way is to wrap your implementation inside a user control and then exposes any interface needed from that user control.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/1/2010 Posts: 18
|
I'm trying to follow your suggestion but actually there's no way to embed a set of columns in a user control. I've simply added a new ascx to the project and did something like this:
<%@ Register TagPrefix="eo" NameSpace="EO.Web" Assembly="EO.Web" %> <eo:TextBoxColumn />
then in the aspx page I included the columns set:
<%@ Register TagPrefix="eo" Namespace="EO.Web" Assembly="EO.Web" %> <%@ Register Src="~/test/ColumnSet.ascx" TagPrefix="Custom" TagName="Name" %>
<eo:Grid runat="server"> <Columns> <Custom:Nome /> </Columns> </eo:Grid>
of course it doesn't work because I think there's no way to use a Column Element without the container in an ascx...so I can't still find a way to embed an arbitrary set of columns with a predefined strategy in a separated component.
My only desire was to craft a CurrencyColumn that's still quite confusing to include in a new Grid. I always need to port javascript handlers and column definition including maskededit segments. It's a shame I cannot build blocks of well known grid patterns. After all it's just a new kind of column. Are you really sure it would be too difficult to inherit the GridColumn and build a new one from scratch? if I could, are there problems using it on the GridColumnCollection inside the regular eo:Grid? and talking about extending the GridColumn, should I just build a new class or an entire ascx?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
No. We didn't mean to put your custom column into a user control (that is not possible). We meant that if you have a Grid that uses a fixed set of columns often, you can then put that Grid inside a user control. If the column set is not fixed but do not change much, then you can have all the columns needed defined there and then dynamically show/hide certain columns. The bottom line is user control always takes controls.
There are two options for your scenario: One option is to inherit MaskedEditColumn; Another option is to implement a "CreateCurrencyColumn" function that you can call from anywhere to create your current column (which is just a MaskedEditColumn with certain properties set to certain things). We do not endorse the first option but would suggest the second option.
It is impossible for you to build a new Grid column from scatch because the Column talks with the Grid through a number of internal interfaces that you would have no access to.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/1/2010 Posts: 18
|
ah ok now it's clear. Honestly I'd really like the first option but it seems I'm not able to do it. I tried several ways: building an ascx that inherits a MaskedEditColumn on the code behind or crafting a simple class that inherits from the same column type, but I couldn't register the control either ways on the page. Actually my knowledge about the whole asp.net world and user controls including child controls it's quite obscure. You said it would be possible to inherit a Column but unfortunately you don't endorse that solution...I'd like to ask you a very little example to start from on my own, but since you said you don't support that way maybe you don't agree on showing me that. Anyway I appreciated the proposal you said about creating the column programmatically. I could start from that...until I (and if I'll ever) find a better solution.
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We don't endorse inheriting the MaskedEditColumn because that is not something we have designed it to do or have tested with. In another word, it's an unknown territory even to us --- all we can say is it MAY work and try at your own risk. But as a commercial product we can not afford to wonder into unknown territories all the time. So it will be much safer and more efficient to stay within what we explicitly support.
Thanks!
|
|