Completed
Last Updated: 07 Nov 2016 11:49 by ADMIN
ADMIN
Hristo
Created on: 02 Nov 2016 14:47
Category: GridView
Type: Bug Report
1
FIX. RadGridView - CompositeFilterForm trims date values to their date part
Workaround: custom CompositeFilterForm 
private void radGridView1_CreateCompositeFilterDialog(object sender, GridViewCreateCompositeFilterDialogEventArgs e)
{
    e.Dialog = new MyCompositeFilterForm();
}

public class MyCompositeFilterForm : CompositeFilterForm
{
    public override void Initialize(GridViewDataColumn dataColumn, Telerik.WinControls.Data.FilterDescriptor filterDescriptor, bool useTypedEditors)
    {
        base.Initialize(dataColumn, filterDescriptor, useTypedEditors);

        if (dataColumn.Name == "Time")
        {
            RadDateTimePicker rEditor = (RadDateTimePicker)this.RightEditor;
            rEditor.DateTimePickerElement.ShowTimePicker = true;
            rEditor.DateTimePickerElement.CalendarSize = new Size(500, 250);

            RadDateTimePicker lEditor = (RadDateTimePicker)this.LeftEditor;
            lEditor.DateTimePickerElement.ShowTimePicker = true;
            lEditor.DateTimePickerElement.CalendarSize = new Size(500, 250);
        }
    }

protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
    base.OnClosing(e);

    if (this.DialogResult == DialogResult.OK)
    {
        object leftValue = this.GetValueFromDateEditor(this.LeftEditor);
        if (leftValue != null)
        {
            this.LeftDescriptor.Value = leftValue;
        }

        object rightValue = this.GetValueFromDateEditor(this.RightEditor);
        if (rightValue != null)
        {
            this.RightDescriptor.Value = rightValue;
        }
    }
}


    protected virtual object GetValueFromDateEditor(RadControl editorControl)
    {
        object value = null;
        if (editorControl is RadDateTimePicker)
        {
            value = ((RadDateTimePicker)editorControl).Value;
            return value;
        }

        return value;
    }
}

0 comments