We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Custom DateTimePicker cell in GGC

Hi,

I want to add some properties like ResetSelectionOnFocus, AutoForwarding, NullString, IsNullDate, NullModeKeyReset. How can I do this ? I have attached a sample

Thanks.

Attachment: DateTimePickerAdvSample_acee4da8.rar

3 Replies

MG Mohanraj Gunasekaran Syncfusion Team May 16, 2017 01:07 PM UTC

Hi Hieudt, 
 
Thanks for using Syncfusion product. 
 
By default, GridGroupingControl does not have the support to add the custom properties for DateTimePickerAdv. But you can add the custom properties in DateTimeCellModel or DateTimeCellRenderer by using the CustomCellModel and CustomCellRenderer which has derived from the DateTimeCellModel and DateTimeCellRenderer. Please refer to the below code example, 
 
Code example 
gridGroupingControl1.TableModel.CellModels.Add("DateTimePicker", new CustomDateTimeCellModel(gridGroupingControl1.TableModel)); 
            this.gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.CellType = "DateTimePicker"; 
 
GridCellRendererBase renderer = this.gridGroupingControl1.TableControl.CellRenderers["DateTimePicker"]; 
CustomDateTimeCellRenderer dateTimeCellRenderer = renderer as CustomDateTimeCellRenderer; 
 
public class CustomDateTimeCellModel : DateTimeCellModel 
{ 
    /// <summary> 
    /// Initializes a new instance of the <see cref="Syncfusion.GridHelperClasses.DateTimeCellModel"/> class. 
    /// </summary> 
    /// <param name="grid">The grid model.</param> 
    public CustomDateTimeCellModel(GridModel grid) 
        : base(grid) 
    { 
    } 
 
    public override GridCellRendererBase CreateRenderer(GridControlBase control) 
    { 
        return new CustomDateTimeCellRenderer(control,this); 
    } 
 
} 
 
public class CustomDateTimeCellRenderer : DateTimeCellRenderer 
{ 
    public CustomDateTimeCellRenderer(GridControlBase grid, GridCellModelBase cellModel) 
        : base(grid, cellModel) 
    { 
        grid.Controls.RemoveAt(1); 
        grid.Controls.Add(new CustomDateTimePicker()); 
    } 
 
    public string Property1 
    { 
        get; 
        set; 
    } 
 
} 
 
 
Screenshot 
 
 
Sample link: GridGroupingControl 
 
Regards, 
Mohanraj G 
 



HI hieudt May 17, 2017 02:44 AM UTC

Hi,

Thanks for your support. I will try it and ask you later


MG Mohanraj Gunasekaran Syncfusion Team May 18, 2017 04:17 AM UTC

Hi Hieudt, 
 
Thanks for your update. 
 
We will wait until here back from you. 
 
Regards, 
Mohanraj G 


Loader.
Up arrow icon