This is a migrated thread and some comments may be shown as answers.

Question about implementing custom columns

5 Answers 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
أشرف
Top achievements
Rank 1
أشرف asked on 19 Nov 2013, 02:52 PM
Greetings,

My manager asked me to achieve some UI behaviours that I thought should be implemented by creating a new grid column type.

I read through the documentation but still can't make my mind on how to achieve the required functionality.

Is it necessary to create a custom column editor (inheriting from GridColumnEditorBase)? Or just inheriting from GridEditableColumn will be sufficient? Taking into account that we plan to use the batch mode heavily, so we will need some client side coding.

Are there any examples covering this subject?

5 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 22 Nov 2013, 08:16 AM
Hi Ashraf,

Based on your description I would suggest using GridTemplateColumn for your scenario instead of extending the GridEditableColumn. It will much cleaner and elegant solution because you will only need to insert the desired controls. 

RadGrid Batch editing functionality will do its best to automatically work with template structure. For example if you have a GridTemplateColumn and place a custom control we have a wide range of controls that we support (both HTML controls and Telerik RadControls). The Batch is created to automatically search for controls and work with them.

There are few cases when the functionality won't be able to automatically determine that it should do:
  • If you have multiple controls in the template which you want to bind from different data fields
  • Controls that are not supported for automatic operations - examples for such controls are the RadColorPicker or any third party controls like jQuery UI or jQuery plugins
In such cases you could resolve your issue by implementing custom handling of such controls. You could take a look at the end of the help article below where it is described how to achieve the functionality.

Regards,
Antonio Stoilkov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
أشرف
Top achievements
Rank 1
answered on 24 Nov 2013, 08:03 AM
Thanks for your suggestion,

I'm tending more towards creating a new column type because of the following reasons:
  • This column will deal with money in local currency, but allow users to enter the amount in foreign currency, and, sometimes, the conversion rate, so, it deals with three data columns (foreign and local currencies, and the conversion rate). I plan to use a RadTooltip to hold the three fields. This is a requirement of the management. They don't want three separate columns, but just one column that displays the local currency amount.
  • I'll need to write JavaScript to populate the fields, retrieve the data from them and write it back to the involved data fields, and to show and hide the tool tip, so I want to encapsulate this JS code in a single component to be easier to reuse be my fellow developers.
  • If I use template columns, I'll need to copy the template contents over and over again, and I can't guarantee that my fellow developers will do this flawlessly.
0
Antonio Stoilkov
Telerik team
answered on 27 Nov 2013, 07:00 AM
Hello Ashraf,

In such case you could create your own column type and extend the GridTemplateColumn class. You could place the desired controls in the InitializeCell method. Additionally, you will need to implement a IGridColumnEditor  which you should return in the CreateDefaultColumnEditor as shown in the example below.
protected override IGridColumnEditor CreateDefaultColumnEditor()
{
    return new YourCustomColumnEditor(this);
}

Regards,
Antonio Stoilkov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
أشرف
Top achievements
Rank 1
answered on 27 Nov 2013, 07:13 AM
I'm currently busy with other issues, concerning RadGrid too, which I'm discussing on other threads. When I return back to this issue, I'll apply your suggestion and give you feedback.

I'm currently also working on an inherited column that just displays a serial (1, 2, 3, …) without any work from the developer. The important part is to make the column cope with batch mode. User deletions and insertions have to update the serial on the client side.
0
Antonio Stoilkov
Telerik team
answered on 02 Dec 2013, 09:17 AM
Hello Ashraf,

Thank you for taking time to give us feedback and provide suggestions. Feel free to contact us whenever you are ready or you have questions related to RadControls.

Regards,
Antonio Stoilkov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
أشرف
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
أشرف
Top achievements
Rank 1
Share this question
or