Developer forum

Forum » Ecommerce - Standard features » How can I create a custom field that displays also the unit of measure (like Depth, Height and Length)

How can I create a custom field that displays also the unit of measure (like Depth, Height and Length)

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I am wondering if there is any way I can create a custom product field that is displayed just like the Depth, Length or Height.
I mean, with a unit at the right of the input field.

Thank you,

Adrian


Replies

 
Nicolai Pedersen
Reply

That is not possible right now.

You can however, create a fieldtype provider that will render a append box.

See examples attached.

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you. I have imagined it should be custom but I was not sure that it could be done even with custom code.

Thank you for sharing your code.

Adrian

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Does this exist as a TFS item already? I see this request "more and more" with customers. The unit might just be a label that's appended to the field value. Making it a string allows for any string the customers would have needs for.

 

Best Regards,

Nuno Aguiar

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

One of my colleagues tried to create a new FieldType and I got this feedback:

".. I see that in Dynamicweb.Ecommerce.FieldTypeProviders dll is defined a class (LengthFieldTypeProvider) that is created from abstract class ConversionUnitFieldTypeProviderBase; I want to create a similar class like  LengthFieldTypeProvider ; I have to create it from my own custom dll; the problem is that I have to overwrite the function  InitalizeOptions ( override Dictionary<string, ConversionUnit> InitalizeOptions()); the problem is that in class ConversionUnitFieldTypeProviderBase function  InitalizeOptions  is declared internal and is not exported in dll to be seen from others dll( internal abstract Dictionary<string, ConversionUnit> InitalizeOptions()).

Can be function InitalizeOptions  declared public or protected so it can be seen from derived classes?

..."

What would be the recommended approach?

Thank you,
Adrian

 

 
Nicolai Pedersen
Reply
This post has been marked as an answer

The base class is also in the project I gave you. Rewirte it or better yet, do not inherit that class, but just copy what you need.

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you. We'll do that.

Adrian

 

You must be logged in to post in the forum