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

Use different editors based on the column values of an item

5 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hamza
Top achievements
Rank 1
Hamza asked on 31 Jul 2018, 08:14 AM

Hi everyone,

 

I have a RadGrid with batchedit mode in a usercontrol, and I want to have different editors based on the type of the parameter. For example : if the parameter is a string, the editor should allow to write strings, or datetime, boolean, integer, even files so the user can download the file and also images so they can appear on the radgrid !

I found something similar to what I want but it's using Kendo UI : https://docs.telerik.com/kendo-ui/knowledge-base/grid-different-editor-based-on-column-value

Any suggestions ?

 

Thank you

5 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 31 Jul 2018, 08:35 AM
Hi Hamza,

You can achieve the target behavior utilizing the EditForm Template functionality of RadGrid. A live demo demonstrating this can be found here:
https://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/form-template-update/defaultcs.aspx

Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Hamza
Top achievements
Rank 1
answered on 31 Jul 2018, 09:38 AM

Hi Vessy,

 

The problem is that I am using BatchEdit RadGrid  : https://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx. And it is actually my user control, so I don't really know how I can use the EditForm Template depending on my "Type" of my object parameter.

 

I'll show you an image so it can be more clear. I'm trying to have exactly the same comportment in the link that I sent in my first post !

In my picture : The parameter "Integer" should allow user to enter only numeric numbers, the "string" one should allow to write exactly only strings and so on for other types..

Regards.

Thank you !

0
Vessy
Telerik team
answered on 02 Aug 2018, 02:37 PM
Hi Hamza,

The behavior shown in the link is actually the default behavior of the Batch edit mode of the Grid - each column is edited depending on its DataType. You can test this behavior in our online demos as well:
https://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

In case the default behavior of the Grid does not fit your needs, you can handle the Gird's CreateColumnEditor event and set the desired Editor type manually in it. You can find useful information on this matter here:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/grid-editors/custom-editors-extending-auto-generated-editors#using-the-createcolumneditor-event
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/grid-editors/auto-generated-editors

Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Hamza
Top achievements
Rank 1
answered on 06 Aug 2018, 07:26 AM

Hello Vessy,

 

Thanks for your answer, the behavior I need is more something like CreateRowEditor, because the value column is related to the type of the item (parameter). And I need to load the editor of the row based on this type. It's like exactly what I showed with the link of kendo UI. But I need it in AJAX UI.

Thank you !

Regards.

Hamza.

0
Vessy
Telerik team
answered on 09 Aug 2018, 07:20 AM
Hi Hamza,

The sample in the linked article is using the column DataField in order to identify the column which editor to change, but you can access the DataType of the column through the same e.column object:
protected void RadGrid1_CreateColumnEditor(object sender, GridCreateColumnEditorEventArgs e)
{
    GridBoundColumn column = e.Column as GridBoundColumn;
    if (column != null && e.Column.DataType.Name == "Boolean")
    {
        //one editor type
    }
    else if (column != null && e.Column.DataType.Name == "String")
    {
        //other editor type
    }
}


Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Hamza
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Hamza
Top achievements
Rank 1
Share this question
or