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

[Solved] Filter on a date column

3 Answers 207 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TIGER
Top achievements
Rank 1
TIGER asked on 21 May 2009, 04:32 AM
Hi,
  I'm using an ObjectDatasource as the datasource for a radgrid object. I came across the following problem and hope if someone can help out:
  1. When a filter command raise the OnSelecting event of the objectdatasource, the MasterView.FilterExpression has the right expression (turn off the enablelinqexpression) for a SQL whereclause, But the grid display without the grid pager ( could not netvigate result set). I found out that must manually set MasterView.FilterExpression="" for the result to be displayed right. Is this a problem ?
 2. Since  MasterView.FilterExpression must be cleared every time a filter is applied, I have to maintain a persistent filter object be veiewstate. Filter object is constructed in the OnItemCommand event handler but for a date field filter the following returned null:
                TextBox filterBox = (e.Item as GridFilteringItem)[filterPair.Second.ToString()].Controls[0] as TextBox;
      is there other ways to access the filter input box of a datetime column ?
3. I down loaded the 2009 Q1 Trial version hoping some of the problem got fixed. After the installation process (uninstall 2008 Q3 then install 2009 Q1) when creating a new websize project in VS 2008, the radcontrols in toolbox are updated but when dragged a RadScriptManager onto the design surface, the control displayed error:"Cannot load assembly Telerik.Web.UI.2009,1.403,35 .....".
Telerik.Web.UI.dll of the right version has been created in the project bin directory though. How could this be fixed ?

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 26 May 2009, 08:38 AM
Hello Tiger,

Straight onto your questions:

1.
When the FilterExpression is set to string.Empty actually the data is not filtered. In my attempt to reproduce described behavior I have created a simple test project. Please examine the attached test project and let me know if I am missing something.

2. Use the same approach, but cast control[0] to RadDatePicker. Here is a code snippet:
((RadDatePicker)((e.Item as GridFilteringItem)[filterPair.Second.ToString()].Controls[0])).SelectedDate 

3. I will suggest you review if somewhere in the site other version of the Telerik.Web.UI is registered. Please verify that you followed this steps when upgrade the version of the RadControls for ASP.NET AJAX.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
TIGER
Top achievements
Rank 1
answered on 28 May 2009, 01:57 AM

Hi, Georgi ;
  Thank you for your reply. I could not find our test project. but here's my code:

    protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        SqlCommand cmd = new SqlCommand();
        SqlCommand cntCmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cntCmd.CommandType = CommandType.Text;

        #region filter processing
        if (FilterExpressions.Count == 0)
        {
            FilterClause = "";
            cmd.CommandText = "SELECT DPTCODE,DPTNAME,SDATE,PAMT,TRIALDAYS FROM DEPARTMENT ";
            cntCmd.CommandText = "SELECT COUNT(*) FROM DEPARTMENT ";
        }
        else
        {
            if (this.RadGrid1.MasterTableView.FilterExpression.Length > 0)
                FilterClause = this.RadGrid1.MasterTableView.FilterExpression;
            cmd.CommandText = "SELECT DPTCODE,DPTNAME,SDATE,PAMT,TRIALDAYS FROM DEPARTMENT WHERE " + FilterClause;
            cntCmd.CommandText = "SELECT COUNT(*) FROM DEPARTMENT WHERE " + FilterClause;
        }
        if (!e.ExecutingSelectCount)
        {
            if (this.RadGrid1.AllowPaging && this.RadGrid1.MasterTableView.GroupByExpressions.Count == 0)
                e.Arguments.MaximumRows = this.RadGrid1.MasterTableView.PageSize;
        }
        else
            this.RadGrid1.MasterTableView.FilterExpression = "";    // without this,the pager row dispears.

        #endregion

        // GetData cmd
        e.InputParameters["sqlcommand"] = (object)cmd;
        // GetRecordCount cmd
        ds.SelectCountCommand = cntCmd;

    }

0
Georgi Krustev
Telerik team
answered on 30 May 2009, 07:39 AM
Hello Tiger,

Based on this information, it is hard to determine what is causing this behavior. If the issue persists, you can open a formal support ticket, and send us a small working project, demonstrating your logic, and the unwanted behavior. We will review it locally, and advise you further.

Best regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
TIGER
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
TIGER
Top achievements
Rank 1
Share this question
or