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

Different Editors

5 Answers 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sergio
Top achievements
Rank 1
Sergio asked on 02 Mar 2015, 09:35 AM
Hi,

I have a gridview with two columns. 

            this.radGridDettagli.MasterTemplate.Columns.Add(newGridViewTextBoxColumn("Name", "Name"));
            this.radGridDettagli.MasterTemplate.Columns.Add(new GridViewTextBoxColumn("Value", "Value"));

The column "Value" could contains different object types. Decimals, String, Date, Enum, etc, ect.

I would like, to use different editors based on the cell value of my column "Name".

Example

Cell value of column "Name" is "ExpiryDate" I need RadDateTimePicker to edit the cell "Value" or the same row
Cell value of column "Name" is "Quantity" I need RadSpinEditor to edit the cell "Value" or the same row
Cell value of column "Name" is "OrderState" I need RadDropDownList to edit the cell "Value" or the same row

RadSpinEditor for numbers, RadDropDownList in case of Enum, RadDateTimePicker in case of Date, RadTextBox in case of string.

Somebody could help me ?

Thanks.

Sergio



5 Answers, 1 is accepted

Sort by
0
Sergio
Top achievements
Rank 1
answered on 03 Mar 2015, 07:31 AM
Someone could help me ?

Thanks.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Mar 2015, 12:04 PM
Hello Sergio,

Thank you for writing.

The RadGridView.EditorRequired is the first event that fires when a cell is to become editable (edit mode). Here is the appropriate place where you can specify what kind of an editor should be used by setting the EditorRequiredEventArgs.EditorType property. Additionally, you can use custom editors if the default one are not suitable for editing the underlying data object.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Dess
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 28 Dec 2016, 04:18 PM

What I am looking to do, is keep the default editor, in my case, a GridSpinEditor, for my Integer column, but I want to set the MIN and MAX values.  I am not sure where or how to do this.  From what I am seeing above, it looks like I will need a custom editor. 

TIA

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Dec 2016, 11:47 AM
Hello Mark,

Thank you for writing.  

You can specify the minimum/maximum for the GridViewDecimalColumn at the column level by setting the Minimum/Maximum properties of the column. However, if you need to specify the different minimum/maximum for each row, it is necessary to handle the  CellEditorInitialized and specify the respective properties to the GridSpinEditor. Here is a sample code snippet:
public RadForm1()
{
    InitializeComponent();
 
    GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("DecimalColumn");
    decimalColumn.Width = 200;
    decimalColumn.Minimum = 0;
    decimalColumn.Maximum = 100;
    radGridView1.MasterTemplate.Columns.Add(decimalColumn);
 
    for (int i = 0; i < 10; i++)
    {
        this.radGridView1.Rows.Add(i);
    }
 
    this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
}
 
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    GridSpinEditor spinEditor = e.ActiveEditor as GridSpinEditor;
    if (spinEditor != null)
    {
        spinEditor.MinValue = 0;
        spinEditor.MaxValue = this.radGridView1.CurrentRow.Index + 1;
    }
}

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 29 Dec 2016, 01:41 PM
Thank you so much, this worked.
Tags
GridView
Asked by
Sergio
Top achievements
Rank 1
Answers by
Sergio
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or