Question about implementing custom columns

6 posts, 0 answers
  1. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 19 Nov 2013 Link to this post

    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?
  2. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 22 Nov 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 24 Nov 2013 Link to this post

    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.
  5. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 27 Nov 2013 Link to this post

    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.
  6. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 27 Nov 2013 Link to this post

    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.
  7. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 02 Dec 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017