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

2 posts, 0 answers
  1. zorro
    zorro avatar
    8 posts
    Member since:
    Mar 2009

    Posted 01 Jul 2012 Link to this post

    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.

  2. zorro
    zorro avatar
    8 posts
    Member since:
    Mar 2009

    Posted 02 Jul 2012 Link to this post

    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();
                }
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top