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

GridDateTimeColumn with EqualTo return right result but does not show on grid

1 Answer 47 Views
Filter
This is a migrated thread and some comments may be shown as answers.
zorro
Top achievements
Rank 1
zorro asked on 01 Jul 2012, 05:15 AM
Hi team,

When I filter the grid by GridDateTime column with "EqualTo" operator and issue only happened with it, the result is right but they are not showed on grid. The total-item on grid is right. Please view my attachment.

In aspx page:
<telerik:RadGrid ID="grid" runat="server" Width="100%" AllowPaging="true" AllowCustomPaging="true"
         ShowGroupPanel="true" AllowFilteringByColumn="true" AllowSorting="true" OnNeedDataSource="grid_NeedDataSource"
                 OnItemCommand="grid_ItemCommand" EnableLinqExpressions="false">
                    <ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true" ReorderColumnsOnClient="true"
                        ColumnsReorderMethod="Reorder">
                        <Animation AllowColumnReorderAnimation="true" AllowColumnRevertAnimation="true" />
                        <ClientEvents OnFilterMenuShowing="FilterMenuShowing" />
                    </ClientSettings>
                    <GroupingSettings CaseSensitive="false" ShowUnGroupButton="true" />
                    <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false" EnableHeaderContextMenu="true" DataKeyNames="InstructorProfileID">
                        <PagerStyle AlwaysVisible="true" />
                        <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" ShowExportToExcelButton="true" />
<Columns>
<telerik:GridDateTimeColumn UniqueName="DateLastLogin" HeaderText="Date of Last Login" SortExpression="DateLastLogin" GroupByExpression="DateLastLogin Group By DateLastLogin"
                                            DataField="DateLastLogin" FilterControlWidth="80%" DataType="System.DateTime" PickerType="DatePicker"/>
<telerik:GridTemplateColumn UniqueName="ReviewStatus" HeaderText="Review Status" SortExpression="ReviewStatus" GroupByExpression="ReviewStatus Group By ReviewStatus"
                                            FilterControlWidth="80%" HeaderStyle-Width="190px" DataField="ReviewStatus" DataType="System.String">
                                <ItemTemplate>
                                    <asp:Label ID="lblReviewStatus" runat="server" Text='<%# Eval("ReviewStatus")%>'/>
                                </ItemTemplate>
                                <FilterTemplate>
                                    <telerik:RadComboBox ID="rcboFilterOptions" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rcboFilterOptions_SelectedIndexChanged">
                                        <Items>
                                            <telerik:RadComboBoxItem Value="ViewAll" Text="View All" />
                                            <telerik:RadComboBoxItem Value="Mine" Text="Mine" />
                                            <telerik:RadComboBoxItem Value="InProgress" Text="In Progress" />
                                            <telerik:RadComboBoxItem Value="NotProcessed" Text="Not Processed" />
                                            <telerik:RadComboBoxItem Value="MissCert" Text="Missing Presentation Skills Certificate" />
                                            <telerik:RadComboBoxItem Value="Accepted" Text="Accepted" />
                                            <telerik:RadComboBoxItem Value="Denied-HPCP" Text="Denied-HPCP" />
                                            <telerik:RadComboBoxItem Value="Denied-PSC" Text="Denied-PSC" />
                                            <telerik:RadComboBoxItem Value="Denied-No Sponsor" Text="Denied-No Sponsor" />
                                            <telerik:RadComboBoxItem Value="Denied-PSC AND HPCP" Text="Denied-PSC AND HPCP" />
                                        </Items>
                                    </telerik:RadComboBox>
                                </FilterTemplate>
                            </telerik:GridTemplateColumn>
</Columns>
                            </MasterTableView>
                </telerik:RadGrid>


In Code Behind:
protected void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
      var totalItem = 0;
      var dataSource = this.InstructorProfileStatusInfoService
                             .GetInstructorProfileStatusInfoCollection(grid.CurrentPageIndex
                                                                        , grid.PageSize
                                 , this.CurrentCriteria
                                                                        , this.UserId, out totalItem);
       grid.DataSource = dataSource ;
            grid.VirtualItemCount = totalItem;
        }
 
protected void rcboFilterOptions_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
 {
            this.grid.CurrentPageIndex = 0;
            var combo = sender as RadComboBox;
            GridFilteringItem filterItem = combo.NamingContainer as GridFilteringItem;
            filterItem.FireCommandEvent(RadGrid.FilterCommandName, new Pair { First = GridKnownFunction.EqualTo.ToString(), Second = "ReviewStatus" });
}
protected void grid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
            if (e.CommandName == RadGrid.FilterCommandName)
            {
                    this.grid.Rebind();
            }
 }

Please help me to solve.
Thanks.

1 Answer, 1 is accepted

Sort by
0
zorro
Top achievements
Rank 1
answered on 02 Jul 2012, 09:41 AM
I solved this issue. Just simple, adding e.Canceled = true; to ItemCommand event handler

protected void grid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
            if (e.CommandName == RadGrid.FilterCommandName)
            {
                e.Canceled = true;
                this.grid.Rebind();
            }
}
Tags
Filter
Asked by
zorro
Top achievements
Rank 1
Answers by
zorro
Top achievements
Rank 1
Share this question
or