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

Filter won't apply during startup

3 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 15 Nov 2010, 05:27 PM
<telerik:GridBoundColumn DataField="CurrentPaymentOrCharge" 
            DataType="System.Decimal" HeaderText="Current Payment Or Charge" 
            SortExpression="CurrentPaymentOrCharge" 
            UniqueName="CurrentPaymentOrCharge" DataFormatString="{0:C}" CurrentFilterFunction="NotEqualTo" CurrentFilterValue="0">
        </telerik:GridBoundColumn>

This is the code for a column I have in my grid. On startup the value is in the filter field and drop down list is defaulted to "not equal to". However on startup the filter is not applied as the default. is there another variable that must be set in order for this filter to be applied on start up or initialization?

Regards.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Nov 2010, 06:39 AM
Hello David,

In order to apply initial filter for a RadGrid control, you need to set the FilterExpression property of the MasterTableView .

ASPX:
<MasterTableView FilterExpression = "([CurrentPaymentOrCharge] <> '0')">

 For more information on this, please refer the following documentation.
Applying default filter on initial load

Thanks,
Princy.
0
David
Top achievements
Rank 1
answered on 16 Nov 2010, 02:31 PM
I tried it but it failed giving parser errors. I thern tried the C# example writing this:

if (!Page.IsPostBack)
{
    RadGrid1.MasterTableView.FilterExpression = "([CurrentPaymentOrCharge] != '0') ";
    GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("CurrentPaymentOrCharge");
    column.CurrentFilterFunction = GridKnownFunction.NotEqualTo;
    column.CurrentFilterValue = "0";
    RadGrid1.MasterTableView.Rebind();
}

I tried substituting "<>" for "!=" but it continues to fail when Rebind is called

Any ideas? If it helps CurrentPaymentOrCharge is a currency value.

I think the error is in FilterExpression. The error I am getting is ""Expression expected""

I also tried this:
RadGrid1.MasterTableView.FilterExpression = "([CurrentPaymentOrCharge] != \'0\') ";
  
and
  
RadGrid1.MasterTableView.FilterExpression = "([CurrentPaymentOrCharge] <> \'0\') ";


0
Marin
Telerik team
answered on 19 Nov 2010, 04:33 PM
Hello David,

The manual filter expressions can be constructed in two ways, depending on the value of the EnableLinqExpression property of the grid. If it is false the format is as shown in the previous posts:
for string expressions
"([CurrentPaymentOrCharge] <> '0')

for integer ones

([CurrentPaymentOrCharge] <> 0)

However the default value for the property is true (in .NET 3.5 and above). So in this case the expression should look like this:
for string values
"(Convert.ToString(it[\"CurrentPaymentOrcharge\"]) <> \"ALFKI\")";

for integer ones

@"Int32(it[""CurrentPaymentOrCharge""]) <> 10248";

For more details on setting the filter expressions manually check the following help topic.

Feel free to ask if you have any other questions.

Sincerely yours,
Marin
the Telerik team
Browse the vast support resources we have to jumpstart 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.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
David
Top achievements
Rank 1
Marin
Telerik team
Share this question
or