I have a grid with filtering enabled, bound to a DataTable object so that it supports automatic sorting.
There is a date field in the table, and as the RadGrid needs the date converting to mm/dd/yyyy format before it will filter correctly, I have intercepted the Filter command, cancelled it, and have rebound the list with the FilterExpression correctly set. See code below.
protected void rgResults_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
try
{
if (e.Item is GridFilteringItem)
{
Pair filterPair = (Pair)e.CommandArgument;
if (e.CommandName == RadGrid.FilterCommandName && filterPair.Second.ToString() == "Date")
{
e.Canceled = true;
GridFilteringItem item = (GridFilteringItem)e.Item;
GridBoundColumn col = (GridBoundColumn)item.OwnerTableView.GetColumnSafe(filterPair.Second.ToString());
DateTime date = DateTime.Parse(col.CurrentFilterValue);
item.OwnerTableView.FilterExpression = string.Format("([{0}] {1} #{2}#)", filterPair.Second.ToString(),
GetOperator(filterPair.First.ToString()), date.ToString("d", new CultureInfo("en-US")));
item.OwnerTableView.Rebind();
}
}
...
To create the filter expression in T-SQL syntax, I need to get the T-SQL equivalent of the RadGrid filter operator. Is there a function I can use to do this? The grid obviously has to do the same to construct the filter expression, so I guess the functionality is in there somewher. Is it available through the API?
Thanks in advance,
There is a date field in the table, and as the RadGrid needs the date converting to mm/dd/yyyy format before it will filter correctly, I have intercepted the Filter command, cancelled it, and have rebound the list with the FilterExpression correctly set. See code below.
protected void rgResults_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
try
{
if (e.Item is GridFilteringItem)
{
Pair filterPair = (Pair)e.CommandArgument;
if (e.CommandName == RadGrid.FilterCommandName && filterPair.Second.ToString() == "Date")
{
e.Canceled = true;
GridFilteringItem item = (GridFilteringItem)e.Item;
GridBoundColumn col = (GridBoundColumn)item.OwnerTableView.GetColumnSafe(filterPair.Second.ToString());
DateTime date = DateTime.Parse(col.CurrentFilterValue);
item.OwnerTableView.FilterExpression = string.Format("([{0}] {1} #{2}#)", filterPair.Second.ToString(),
GetOperator(filterPair.First.ToString()), date.ToString("d", new CultureInfo("en-US")));
item.OwnerTableView.Rebind();
}
}
...
To create the filter expression in T-SQL syntax, I need to get the T-SQL equivalent of the RadGrid filter operator. Is there a function I can use to do this? The grid obviously has to do the same to construct the filter expression, so I guess the functionality is in there somewher. Is it available through the API?
Thanks in advance,