Define different column types in single column

5 posts, 0 answers
  1. Harry
    Harry avatar
    1 posts
    Member since:
    Sep 2010

    Posted 29 Sep 2010 Link to this post

    Is it possible to define different GridView column type based on column value at row loading event at runtime?
    I like to be able to define calendar, combo, or text in the same column.

    For example, I have following records:
    Col1        Col2            Col3
    Daily        10/1/2010    Check my email
    Weekly    Monday        Check to see if weekly backup worked
    Monthly    1                  Check to see if monthly order came thru

    I like to be able to change cell column type on Col2 based on value in Col1.
    So, in this case,
    Col2 on the 1st row has GridViewDataTimeColumn where a user can select date from calendar. 
    Col2 on the 2nd row has combo box with monday, tuesday, wednesday, etc...
    Col3 on the 3rd row has free text where a user can enter numerical number 1 thru 31

    So, Col1 is defined as combo box with Daily, Weekly, Monthly, etc...

    Is this possible to do this using your radgridview?


    Harry Idachi

  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 30 Sep 2010 Link to this post

    Hello Harry,

    Sadly i don't think it's possible to accomplish what you are trying to do here, because by construction, a column holds the same type on all rows, but that doesn't mean you cannot create a text column and on validation to do the necessary checks based on RowInfo and the previous cell.

    You should take a look at this article about Cell validation

    If you have any other questions, please do not hesitate to say so.

    Best Regards,
    Emanuel Varga
  3. DevCraft R3 2016 release webinar banner
  4. Ramius
    Ramius avatar
    127 posts
    Member since:
    Feb 2008

    Posted 30 Sep 2010 Link to this post

    Hello Harry,

    you can do this with the GridView and the EditorRequired Event. 

    In the EditorRequired Event you can create the Editor for the cell in Col2 based on the value in Col1. 

    Best Regards,


  5. Sheraz Naseeb
    Sheraz Naseeb avatar
    22 posts
    Member since:
    Mar 2010

    Posted 30 Sep 2010 Link to this post

    Actually I need some sort of similar functionality, whats happening is I am saving dates in to database as String or Integer, when it comes to the datagrid I use the CellFormatting event to get it into date format.

    Now, when I go to the filtering cell it shows a text box for filtering and if it is date column into the database then it shows a DateTimePickerElement into the filtering row.

    Is there anyway I can get the RadDateTimePickerElement into the filtering cell when the column data type is string or integer? and also how to get access selected date from that DatePickerElement when it is clicked???

    Please help...

  6. Svett
    Svett avatar
    728 posts

    Posted 05 Oct 2010 Link to this post

    Hi Sheraz,

    You can use the EditorRequired event where you can replace the default editor for the filter cell. You can read more about it in the online documentation. You can determine the value that the editor should commit to your data source by creating a custom editor:

    public class MyDateTimeEditor : RadDateTimeEditor
        public override object Value
                GridCellElement cellElement = this.OwnerElement as GridCellElement;
                if (cellElement != null && cellElement.ColumnInfo.Name == "YourStringColumnName")
                    RadDateTimePickerElement element = this.EditorElement as RadDateTimePickerElement;
                    DateTime value = element.Value;
                    return CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(value.Month);
                return base.Value;
                base.Value = value;


    You have to replace the default editor:
    private void radGridView1_EditorRequired(object sender, Telerik.WinControls.UI.EditorRequiredEventArgs e)
        if (this.radGridView1.CurrentColumn.Name == "ColumnThatShouldHaveDateTimeEditor")
            e.EditorType = typeof(MyDateTimeEditor);

    I hope this helps.

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft R3 2016 release webinar banner