Hi
I am trying to leverage the c# code you have at the following url:
http://www.telerik.com/help/aspnet/grid/grdfilteringfordatetimecolumnwithdataformatstring.html
Whilst there are several syntax errors I have been able to overcome most of them,
but the following line has me stumped:
string currentPattern = (TextBox)filterItem(((Pair)e.CommandArgument).Second).Controls(0).Text;
I get an error which says.
'filterItem is a variable but it is used like a method'.
What is this line supposed to be?
In the process you might want to clean up the other syntax errors too.
TIA
I am trying to leverage the c# code you have at the following url:
http://www.telerik.com/help/aspnet/grid/grdfilteringfordatetimecolumnwithdataformatstring.html
Whilst there are several syntax errors I have been able to overcome most of them,
but the following line has me stumped:
string currentPattern = (TextBox)filterItem(((Pair)e.CommandArgument).Second).Controls(0).Text;
I get an error which says.
'filterItem is a variable but it is used like a method'.
What is this line supposed to be?
In the process you might want to clean up the other syntax errors too.
TIA
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 14 Jun 2011, 02:51 PM
Hello Tim,
I suppose you are using the ASP.NET AJAX version. If that is the case try like this.
C#:
Also check out the documentation.
Filtering for DateTime bound column with DataFormatString different than mm/dd/yyyy.
Thanks,
Princy.
I suppose you are using the ASP.NET AJAX version. If that is the case try like this.
C#:
string
currentPattern = (filterItem[((Pair)e.CommandArgument).Second.ToString()].Controls[0]
as
TextBox).Text;
Also check out the documentation.
Filtering for DateTime bound column with DataFormatString different than mm/dd/yyyy.
Thanks,
Princy.
0

Tim
Top achievements
Rank 1
answered on 14 Jun 2011, 03:41 PM
Hi Princy
Thanks for your quick response.
You are absolutely right I am using ASP.NET.
I did find some code that looks like what you described, but I still can't resolve my underlying problem.
I have a GridDateTimeColumn, defined as follows:
The data in the column presents as mm/dd/yyy hh:mm:ss AM
However when I select a time there is no seconds component.
Also the filtering does not seem to apply correctly.
I am trying to understand your articles on how to do date filtering but I'm not understanding
what I need to do to meet our UI requirements.
TIA
Thanks for your quick response.
You are absolutely right I am using ASP.NET.
I did find some code that looks like what you described, but I still can't resolve my underlying problem.
I have a GridDateTimeColumn, defined as follows:
<telerik:GridDateTimeColumn DataField="FirstConn" HeaderText="First Connection" UniqueName="firstConnection"
PickerType="DateTimePicker" ItemStyle-Wrap="False">
</telerik:GridDateTimeColumn>
I have to use a DateTimePicker because we want to see the Text element, the calendar icon,
the time icon, and the filter icon.
The data in the column presents as mm/dd/yyy hh:mm:ss AM
However when I select a time there is no seconds component.
Also the filtering does not seem to apply correctly.
I am trying to understand your articles on how to do date filtering but I'm not understanding
what I need to do to meet our UI requirements.
TIA
0

Tim
Top achievements
Rank 1
answered on 14 Jun 2011, 04:18 PM
Hi Princy
Thanks for you help, but I think I have resolved the problem.
I totally missed the fact that I had to set the DataType on my column to System.DateTime.
I assumed, foolishly, that since I was using a GridDateTimeColumn and is was presenting as a date
that everything was correctly defined.
I guess maybe under the covers it was just treating it as a string.
An added bonus.
I get a smaller list of filter choices that are more appropriate for dates.
Now if I can just get the time picker to present hours, minutes, AND seconds.
Thanks for you help, but I think I have resolved the problem.
I totally missed the fact that I had to set the DataType on my column to System.DateTime.
I assumed, foolishly, that since I was using a GridDateTimeColumn and is was presenting as a date
that everything was correctly defined.
I guess maybe under the covers it was just treating it as a string.
An added bonus.
I get a smaller list of filter choices that are more appropriate for dates.
Now if I can just get the time picker to present hours, minutes, AND seconds.
0

GTL Dev
Top achievements
Rank 2
answered on 16 Jun 2011, 03:56 PM
if you figure out how to get the seconds in there could post it here, I am looking for the same solution but havent made any progress yet.
Thanks.
Thanks.
0
Hi there,
Hope this helps.Regards,
Marin
the Telerik team
You can try the following approach to configure the format in the DateTimePicker to show seconds as well. Then you proceed as the way described in the help topic with handling the ItemCommand and filtering appropriately.
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
GridFilteringItem filterItem = e.Item
as
GridFilteringItem;
if
(filterItem!=
null
)
{
RadDateTimePicker dateTimePicker = filterItem[
"ShippedDate"
].Controls[0]
as
RadDateTimePicker;
dateTimePicker.DateInput.DateFormat =
"MM/dd/yyyy hh:mm:ss"
;
dateTimePicker.DateInput.DisplayDateFormat =
"MM/dd/yyyy hh:mm:ss"
;
}
}
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName==RadGrid.FilterCommandName)
{
string
fieldName = (e.CommandArgument
as
System.Web.UI.Pair).Second.ToString();
string
filterFunction = (e.CommandArgument
as
System.Web.UI.Pair).First.ToString();
string
filterValue = ((e.Item
as
GridFilteringItem)[
"ShippedDate"
].Controls[0]
as
RadDateTimePicker).SelectedDate.Value.ToString();
//filter the datasource of the grid and rebind
//RadGrid1.Rebind();
}
}
Hope this helps.Regards,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.