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

IsFilter Applied? RadGridVeiw

4 Answers 224 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sheraz Naseeb
Top achievements
Rank 1
Sheraz Naseeb asked on 15 Sep 2010, 03:06 PM
Hi Telerik Team,

I would like to have following functionality in the grid.

1. For example, If I apply filter on some date and price column and not on any other column. Can I change the colour of these two filter cells or something else to differentiate these two filter cells from the rest of the row. Because it does not show anything in the filtering cell when we apply BETWEEN filter. But if we apply Equals or anyother filter it shows the value into the cell.

2. Next thing can I filter these columns programmatically as we dont always want to use the filtering row. Please advice how can it be done, I somehow managed to do filteration programmatically but again I am unable to do the BETWEEN bit of it, all of the other criteria can be done.

3. How can I save the filter criteria and their values for each column seperately into a file or database.

I am using Q1 2009.

Thanks for your help,

Sheraz

4 Answers, 1 is accepted

Sort by
0
Sheraz Naseeb
Top achievements
Rank 1
answered on 21 Sep 2010, 10:24 AM
Hello Telerik Team,

Any answer or update on above questions... or shall I consider its not possible.

Many thanks,

Sheraz
0
Alexander
Telerik team
answered on 21 Sep 2010, 11:29 AM
Hello Sheraz,

Thank you for your questions. In Q1 2009 version of RadGridView you could achieve this functionality following the steps below:

1. Please use the ViewCellFormatting event to define the visual appearance for any specific RadGridView cell at runtime:
private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    GridFilterCellElement cell = e.CellElement as GridFilterCellElement;
    if (cell != null && cell.ColumnIndex == 0)
    {
        cell.DrawFill = true;
        cell.NumberOfColors = 1;
        cell.BackColor = Color.Red;
    }
}

2. You can create a FilterExpression with Between operator using the following code snippet:
FilterExpression filter = new FilterExpression(
    FilterExpression.BinaryOperation.AND, GridKnownFunction.Between, new object[] { 1, 7 });
this.radGridView1.Columns["ColumnName"].Filter = filter;

3. Please review the SaveLayout functionality of RadGridView.

I would highly encourage you to try the latest version of the RadGridView control. It introduces the FilterDescriptors collection which is more powerful and easier to use than the FilterExpressions.

Best regards,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sheraz Naseeb
Top achievements
Rank 1
answered on 21 Sep 2010, 02:01 PM
I guess I could not explain myself properly, but thanks because the BETWEEN filter is working.

Now, what I would like to have is, I only want to change the filtering row cell color of the cell on which the filter is applied and dont want to specify with a column index as you did in your example as "cell.ColumnIndex = 0", so it says in the title of this post "IsFilter Applied".

The second one is working perfectly fine.

And the third one is I know how to save and load the layouts and I am working around them very well. But I want to save the filteration criteria into the database to use it later for some other purposes.

I hope it makes things a bit more clear, waiting for your reply.

Many thanks,

Sheraz
0
Alexander
Telerik team
answered on 24 Sep 2010, 02:01 PM
Hello Sheraz,

You can check if a filter is applied to a RadGridView column using its Filter property. In the example with the ViewCellFormatting code snippet you can replace the ColumnIndex check with the following code:
this.radGridView1.Columns[cell.ColumnIndex].Filter != null

As to your second question, there is no ready-to-use method to save the FilterExpressions to a database. The SaveLayout feature, however, will create the following xml output for our example with the Between filter predicate:
<Telerik.WinControls.UI.GridViewDecimalColumn IsAutoGenerated="True" FieldName="ID" UniqueName="ID" HeaderText="ID" IsVisible="True">
  <Filter FieldName="ID">
    <Predicates>
      <Telerik.WinControls.Data.FilterPredicate Function="Between">
        <Values>
          <System.Int32>1</System.Int32>
          <System.Int32>7</System.Int32>
        </Values>
      </Telerik.WinControls.Data.FilterPredicate>
    </Predicates>
  </Filter>
</Telerik.WinControls.UI.GridViewDecimalColumn>

It is the data you need to recreate the FilterExpression. You can save it in the database as a text or in a more convenient for your case form.

Greetings,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Sheraz Naseeb
Top achievements
Rank 1
Answers by
Sheraz Naseeb
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or