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

RadGrid DateTimeColumn Filter

7 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prakash
Top achievements
Rank 1
Prakash asked on 24 Jul 2015, 06:10 AM

Hi Team,

 

I have RadGrid which is populated via NeedDataSource Event.. In the ​grid, One of the column is DateTimeColumn.. Now, I want to add ​Date And Time Filter for this column.. So, I set the PickerType to DateTimePicker.. Now, It shows date control and time control.. But, when I select the time control it shows only hours and minutes.. ​whereas we need hour, minutes and seconds also should be shown.. Please let me know how to achieve this...

 

Thanks,

Prakash..

7 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 28 Jul 2015, 12:02 PM
Hi,

 In order to achieve this scenario you can obtain a reference to the filter box of the column in the ItemCreated event, and set the DateFormat mask for the date input control:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        RadDateTimePicker picker = ((GridFilteringItem)e.Item)["DateTimeColumn"].Controls[0] as RadDateTimePicker;
        if (picker != null)
        {
            picker.DateInput.DateFormat = "M/d/yyyy hh:mm:ss";
        }
    }
}



Regards,
Maria Ilieva
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Prakash
Top achievements
Rank 1
answered on 29 Jul 2015, 06:49 AM

Hi

The solution didn't work for me..

The column details which I used is below,  

Please let me know,

1. How to the show the seconds in the time ticker

2. Filtering the records based on Date and Time

<telerik:GridDateTimeColumn

EnableTimeIndependentFiltering="true" PickerType="DateTimePicker"​

DataFormatString="{0:MM/dd/yyyy hh:mm:ss}" 

FilterDateFormat="{0:MM/dd/yyyy hh:mm:ss}"

HeaderText="Deleted Date"  

DataType="System.DateTime"

DataField="DeletedOn"  

FilterControlWidth="75%"  

UniqueName="DeletedOn"

FilterControlAltText="Filter DeletedOnColumn">

</telerik:GridDateTimeColumn>

 

Thanks In Advance,

Prakash.

0
Maria Ilieva
Telerik team
answered on 31 Jul 2015, 02:43 PM
Hi,

Тry using template column with DateTimePicker in it and add the following settings to the picker:

<telerik:RadDateTimePicker ID="RadDateTimePicker1"  ZIndex="30001" runat="server" DbSelectedDate='<%# Bind("StartTime", "{0:T}") %>'>
  <TimeView runat="server" TimeFormat="HH:mm:ss">
  </TimeView>
  <DateInput ID="DateInput1" runat="server" DateFormat="MM/dd/yyyy hh:mm:ss" DisplayDateFormat="MM/dd/yyyy hh:mm:ss">
  </DateInput>
</telerik:RadDateTimePicker>


Regards,
Maria Ilieva
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Prakash
Top achievements
Rank 1
answered on 02 Aug 2015, 04:20 PM

Seems there was misunderstanding I guess.. 

I have GridDateTimeColumn and values is DateTime value.. I'm able to display the value with Date and Time..

Now, My requirement is I need to add filter with both date and time option.. 

By default it shows the Date Picker.. If I change the Picker Type to DateTime, it shows both Date and Time picker.. But the problem, the time picker shows only hour and minute.. but I want hour, minute and seconds should be selected from the Time Picker.. so that it filters the value based on date and time.. 

To add more.. my input values 07/01/2015 04:44:32, 07/06/2015 06:33:55.. 

Now I want to filter the value with both Date and Time (hh:mm:ss) 

 Please guide with proper inputs as early as possible.. 

Thanks In Advance..

0
Maria Ilieva
Telerik team
answered on 05 Aug 2015, 01:39 PM
Hello,

In this case the correct approach here is to set a FilterDateFormat string so that the time part (including the seconds) of the date does not get escaped. Attached is a sample example that demonstrates this approach.
It is not possible to add Seconds in the TimeView of the TimePicker control however you can manually modify the seconds in the filter filed.

Regards,
Maria Ilieva
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Prakash
Top achievements
Rank 1
answered on 07 Aug 2015, 03:39 AM

Thanks Maria..

 I tried your solution but I didn't shows the seconds in the filter.. Please refer the image(Filter.jpg).. This is the result of the example..

but I want seconds also should be displayed in the timer.. Please refer ​the image (ExpectedFilterTimer.jpg).. This is what I want..

Please let me know how to do that..

 

Thanks In Advance..

 

0
Maria Ilieva
Telerik team
answered on 11 Aug 2015, 12:30 PM
Hello,

Try setting TimeFormt for the filter item like this:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        GridFilteringItem filteringItem = e.Item as GridFilteringItem;
        RadDateTimePicker picker = filteringItem["Date"].Controls[0] as RadDateTimePicker;
        picker.SharedTimeView.TimeFormat = "HH:mm:ss";
        picker.SharedTimeView.Interval = new TimeSpan(0, 45, 0);
    }
}


Regards,
Maria Ilieva
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Prakash
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Prakash
Top achievements
Rank 1
Share this question
or