Hi,
I have a requirement to change datetime format from mm/dd/yyyy to yyyy-mm-dd in filter textbox (not the data value).
I am using
I have a requirement to change datetime format from mm/dd/yyyy to yyyy-mm-dd in filter textbox (not the data value).
I am using
datetimeColumn.DataFormatString =
"{0:yyyy-MM-dd}";
but looks like only data value format has changed and filter textbox data format is still MM-dd-yyyy after selecting date from calendar control.
Any idea to fix this.
Thanks,
Sam
4 Answers, 1 is accepted
0
Accepted
Hello Sam,
The DateFormat of the filtering date picker can be changed programmatically:
ASPX
C#
If the date column has no explicit UniqueName set, then the unique name is the corresponding data field.
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The DateFormat of the filtering date picker can be changed programmatically:
ASPX
| <telerik:RadGrid |
| ID="RadGrid1" |
| runat="server" |
| AllowFilteringByColumn="true" |
| OnItemCreated="RadGrid1_ItemCreated" /> |
C#
| protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridFilteringItem) |
| { |
| ((e.Item as GridFilteringItem)["DateColumnUniqueName"].Controls[0] as RadDatePicker).DateInput.DateFormat = "yyyy-MMM-dd"; |
| } |
| } |
If the date column has no explicit UniqueName set, then the unique name is the corresponding data field.
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Samnang
Top achievements
Rank 1
answered on 08 Sep 2009, 07:51 PM
Thanks.
Sam
Sam
0
Bill
Top achievements
Rank 1
answered on 25 Jan 2010, 05:21 PM
My DataFormatString is like so: {0:MMM-DD-YYYY}
Is there anyway to do a Filter Function on a RadGrid like:
1. Between MMM-DD-YYYY to MMM-DD-YYYY ?
2. Month only?
3. Year only?
My RadGrid Code
Is there anyway to do a Filter Function on a RadGrid like:
1. Between MMM-DD-YYYY to MMM-DD-YYYY ?
2. Month only?
3. Year only?
My RadGrid Code
| <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ProblemsSDS" GridLines="None" |
| Skin="Vista" Style="position: static" AllowFilteringByColumn="True" AllowPaging="True" |
| AllowSorting="True" OnItemInserted="RadGrid1_ItemInserted" BorderColor="White" BorderStyle="Solid" BorderWidth="1px" Width="100%" OnItemCreated="RadGrid1_ItemCreated" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"> |
| <MasterTableView AutoGenerateColumns="False" DataKeyNames="ProblemID" DataSourceID="ProblemsSDS" |
| CommandItemDisplay="Top"> |
| <Column> |
| <telerik:GridDateTimeColumn DataField="ProblemDate" DataType="System.DateTime" UniqueName="ProblemDate" PickerType="DateTimePicker" FilterImageTooltip="Filter example: mmm-dd-yyyy to mmm-dd-yyyy select 'EqualTo'" |
| SortExpression="ProblemDate" HeaderText="Problem Date/Time" DataFormatString="{0:MMM-dd-yyyy} {0:t}" FilterControlWidth="125px" DefaultInsertValue="" AllowFiltering="true" CurrentFilterFunction="Between"> |
| <HeaderStyle Width="125px" /> |
| </telerik:GridDateTimeColumn> |
| </Column> |
| </RadGrid> |
CS code
| protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridFilteringItem) |
| { |
| ((e.Item as GridFilteringItem)["ProblemDate"].Controls[0] as RadDatePicker).DateInput.DateFormat = "MMM-dd-yyyy"; |
| } |
| } |
Bill
0
Hello Bill,
To see more information along the lines of the requested information, please refer to the following topic:
http://www.telerik.com/help/aspnet-ajax/grdfilteringfordatetimecolumnwithdataformatstring.html
This can be further modified to handle filtering by date only, or by year only.
I hope this gets you started properly.
Greetings,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
To see more information along the lines of the requested information, please refer to the following topic:
http://www.telerik.com/help/aspnet-ajax/grdfilteringfordatetimecolumnwithdataformatstring.html
This can be further modified to handle filtering by date only, or by year only.
I hope this gets you started properly.
Greetings,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
