In the FilterExpression, I noticed Telerik is using ")||(" instead of ")OR(". Evidently this works, but I believe the recommendation is "OR". I only bring this up because in many situations, the RadGrid1.MasterTableView.FilterExpression can be used directly as the WHERE clause is in a SQL Query. SQL understands "OR", but not "||".
I'm using it for my where clause in my project to retrieve related data, so you might consider changing it just for me. :-)
In the meantime RadGrid1.MasterTableView.FilterExpression.Replace("||", "OR") is working well.
Thanks!
I'm using it for my where clause in my project to retrieve related data, so you might consider changing it just for me. :-)
In the meantime RadGrid1.MasterTableView.FilterExpression.Replace("||", "OR") is working well.
Thanks!
9 Answers, 1 is accepted
0
Hello Jon,
The FilterExpression for the RadGrid use "OR" and "AND" operators. If you would like, you could check the difference when using various data sources in this article. I am afraid that the "||" operator is not used.
This said, would you elaborate more on the configuration that you have. What are the settings for the RadGrid? I would appreciate it if you could share your full markup with the code-behind so we could have better understanding of your scenario. Thank you in advance.
Regards,
Viktor Tachev
Telerik
The FilterExpression for the RadGrid use "OR" and "AND" operators. If you would like, you could check the difference when using various data sources in this article. I am afraid that the "||" operator is not used.
This said, would you elaborate more on the configuration that you have. What are the settings for the RadGrid? I would appreciate it if you could share your full markup with the code-behind so we could have better understanding of your scenario. Thank you in advance.
Regards,
Viktor Tachev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Gaurab
Top achievements
Rank 1
answered on 01 Jul 2014, 07:37 PM
In the OnNeedDataSource, if you check the FilterExpression, it is using "||". I replaced it with "OR" as in the following:
Is this not the code that creates the filter?
Maybe I'm misunderstanding something...
var filter Expression = RadGrid1.MasterTableView.FilterExpression.Replace(
"||"
,
"OR"
);
Is this not the code that creates the filter?
public
virtual
string
EvaluateFilterExpression(GridFilteringItem filteringItem)
{
if
(!
this
.SupportsFiltering())
{
return
string
.Empty;
}
TableCell cell = filteringItem[
this
.UniqueName];
string
filterValue =
this
.GetCurrentFilterValueFromControl(cell);
if
(
this
.ListOfFilterValues !=
null
&&
this
.ListOfFilterValues.Length > 0)
{
if
(
this
.CurrentFilterFunction == GridKnownFunction.EqualTo)
{
GridFilterFunction filterFunc =
new
GridFilterFunction(
this
.CurrentFilterFunction);
StringBuilder exprBuilder =
new
StringBuilder();
exprBuilder.Append(
"("
);
exprBuilder.Append(filterFunc.GetFunctionString(
this
.GetFilterDataField(),
this
.ListOfFilterValues[0],
this
.DataType, filteringItem.OwnerTableView));
for
(
int
i = 1; i <
this
.ListOfFilterValues.Length; i++)
{
string
filterPart = filterFunc.GetFunctionString(
this
.GetFilterDataField(),
this
.ListOfFilterValues[i],
this
.DataType, filteringItem.OwnerTableView);
if
(!
string
.IsNullOrEmpty(filterPart))
{
exprBuilder.Append(
")||("
);
exprBuilder.Append(filterPart);
}
}
exprBuilder.Append(
")"
);
return
exprBuilder.ToString();
}
else
if
(
this
.CurrentFilterFunction == GridKnownFunction.NoFilter)
{
this
.ListOfFilterValues =
null
;
}
}
if
(String.IsNullOrEmpty(filterValue) && !FunctionTakesNoArguments(
this
.CurrentFilterFunction))
{
return
""
;
}
else
{
GridFilterFunction filterFunc =
new
GridFilterFunction(
this
.CurrentFilterFunction);
//Get DataType of colum
return
filterFunc.GetFunctionString(
this
.GetFilterDataField(), filterValue,
this
.DataType, filteringItem.OwnerTableView);
}
}
Maybe I'm misunderstanding something...
0
Gaurab
Top achievements
Rank 1
answered on 01 Jul 2014, 07:40 PM
To clarify, this is occurring when using a checkboxlist for a filter.
0
Hi Jon,
Thank you for the clarification.
I am afraid that modifying the generated FilterExpression at this point would not be possible as it would introduce a breaking change.
If you would like to use it directly to query a database you could use the approach that you currently have implemented - replacing the "||" string with "OR".
Regards,
Viktor Tachev
Telerik
Thank you for the clarification.
I am afraid that modifying the generated FilterExpression at this point would not be possible as it would introduce a breaking change.
If you would like to use it directly to query a database you could use the approach that you currently have implemented - replacing the "||" string with "OR".
Regards,
Viktor Tachev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Gaurab
Top achievements
Rank 1
answered on 07 Jul 2014, 04:19 PM
Sounds good. I don't blame you for not changing it. I had noticed it and I saw on the page you referred to that it showed using an "OR", but it was using "||". So, I thought I'd bring it up in case you wanted to change it, or the documentation, in the future.
Thanks for your feedback.
Thanks for your feedback.
0
Vivek
Top achievements
Rank 1
answered on 12 Aug 2014, 06:08 AM
I am having a similar problem. I need to set ListOfFilterValues = Nothing for a GridBoundColumn. My code is as follows:
If TypeOf column Is GridBoundColumn Then
Dim boundColumn As GridBoundColumn = TryCast(column, GridBoundColumn)
boundColumn.FilterListOptions = GridFilterListOptions.AllowAllFilters
DirectCast(column, Telerik.Web.UI.GridBoundColumn).ListOfFilterValues = Nothing
End If
However I am getting the error
Error 1 'Telerik.Web.UI.GridColumn.Protected Friend Property ListOfFilterValues As String()' is not accessible in this context because it is 'Protected Friend'.
Any solution?
Thanks
If TypeOf column Is GridBoundColumn Then
Dim boundColumn As GridBoundColumn = TryCast(column, GridBoundColumn)
boundColumn.FilterListOptions = GridFilterListOptions.AllowAllFilters
DirectCast(column, Telerik.Web.UI.GridBoundColumn).ListOfFilterValues = Nothing
End If
However I am getting the error
Error 1 'Telerik.Web.UI.GridColumn.Protected Friend Property ListOfFilterValues As String()' is not accessible in this context because it is 'Protected Friend'.
Any solution?
Thanks
0
Hi Vivek,
If you would like to clear the filters that are applied in the RadGrid you could use an approach similar to the one below. It illustrates how you could clear the filters in the grid when a Button is clicked:
Regards,
Viktor Tachev
Telerik
If you would like to clear the filters that are applied in the RadGrid you could use an approach similar to the one below. It illustrates how you could clear the filters in the grid when a Button is clicked:
Protected
Sub
clrFilters_Click(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
For
Each
column
As
GridColumn
In
RadGrid1.MasterTableView.Columns
column.CurrentFilterFunction = GridKnownFunction.NoFilter
column.CurrentFilterValue =
String
.Empty
Next
RadGrid1.MasterTableView.FilterExpression =
String
.Empty
RadGrid1.MasterTableView.Rebind()
End
Sub
Regards,
Viktor Tachev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Vivek
Top achievements
Rank 1
answered on 14 Aug 2014, 10:39 PM
Hi Viktor,
Thanks for your reply. I tried your solution. It works
partially. I have explained my problem in the attached document. Please let me
know if you need any more clarification.
Attachment failed. So I have emailed the attachment.
Thanks
Vivek Arkalgud
Thanks for your reply. I tried your solution. It works
partially. I have explained my problem in the attached document. Please let me
know if you need any more clarification.
Attachment failed. So I have emailed the attachment.
Thanks
Vivek Arkalgud
0
Hi Vivek,
Would you send a formal support ticket and attach the files there? This would enable us to investigate the issue locally and look for its cause.
Regards,
Viktor Tachev
Telerik
Would you send a formal support ticket and attach the files there? This would enable us to investigate the issue locally and look for its cause.
Regards,
Viktor Tachev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.