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

Freezing columns in a radgrid

5 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mithun Pentuker
Top achievements
Rank 1
Mithun Pentuker asked on 16 Jan 2013, 07:52 AM
Hi, I am trying to freeze the first four columns of my telerik radgrid. However, on implementation I get the following UI issue as seen in the attached screenshot.
The telerik version used by me is 2010.3.1109.35.
And , the code snippet used is :
 <ClientSettings> 
        <Scrolling AllowScroll="true" FrozenColumnsCount="4" SaveScrollPosition="true" UseStaticHeaders="true" /> 
    <ClientEvents  /> 
    </ClientSettings> 


  How can I fix it?

Looking forward to your suggestions.

5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 16 Jan 2013, 08:11 AM
Hello,

Can you verify that this problem persists with the latest version of RadControls for ASP.NET AJAX?

Kind regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Mithun Pentuker
Top achievements
Rank 1
answered on 16 Jan 2013, 08:22 AM
Hi Pavlina

Thanks for the quick response. We recently moved from 2009 to 2010 version of Telerik and had a tough time in resolving the UI issues resulting out of this migration. We presently don't have a plan or bandwidth to move to any latest versions. Could you please help us with the existing version and implementation.
0
Pavlina
Telerik team
answered on 16 Jan 2013, 10:51 AM
Hello,

Based on the provided information it would be hard to determine what might be the cause for the issue you are facing. We need your aspx code and the related code behind in order to investigate this problem.

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Mithun Pentuker
Top achievements
Rank 1
answered on 16 Jan 2013, 11:19 AM
Please find both the ascx and the code behind below.

<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="MyArchives.ascx.cs" Inherits="Deloitte.WAU.Site.UserControls.ArchivesList" %>

 

<%@ Import Namespace="Deloitte.WAU.Site" %>

 

<telerik:RadGrid ID="ArchiveListRadGrid" runat="server" PageSize="20" AllowPaging="true"

    AllowCustomPaging="true"

    AllowSorting="True"

    AllowMultiRowSelection="false"

    OnSortCommand="ArchiveListRadGridSortCommand"

    OnNeedDataSource="ArchiveListRadGrid_NeedDataSource"

    OnItemDataBound="ArchiveListRadGrid_ItemDataBound">

    <MasterTableView

        DataKeyNames="ArchiveNumber"

        EnableNoRecordsTemplate="true"

        AllowMultiColumnSorting="true">

        <NoRecordsTemplate>

            <div>There are no records to display</div>

        </NoRecordsTemplate>

        <SortExpressions>

          

            <telerik:GridSortExpression FieldName="ExpectedDocumentationCompletionDate" SortOrder="Ascending" />

        </SortExpressions>

        <Columns>

         <telerik:GridBoundColumn DataField="ExpectedDocumentationCompletionDate" HeaderText="Expected Documentation<br/>Completion Date"

                DataFormatString="{0:MM'/'dd'/'yyyy}" ItemStyle-HorizontalAlign="Center"

                HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" HeaderStyle-Width="120px"

                SortExpression="ExpectedDocumentationCompletionDate" UniqueName="ExpectedDocumentationCompletionDate" />

            <telerik:GridBoundColumn DataField="ArchiveDueDate" HeaderText="Required Documentation<br/>Completion Date"

                DataFormatString="{0:MM'/'dd'/'yyyy}" ItemStyle-HorizontalAlign="Center"

                HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" HeaderStyle-Width="120px"

                SortExpression="ArchiveDueDate" UniqueName="ArchiveDueDate" />

            <telerik:GridBoundColumn DataField="ClientName" HeaderText="Client<br/>Name" HeaderStyle-Width="150px"

                HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" SortExpression="ClientName"

                UniqueName="ClientName" />

            <telerik:GridTemplateColumn HeaderText="Archive<br/>Number" HeaderStyle-Width="80px"

                HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" ItemStyle-HorizontalAlign="Center"

                SortExpression="ArchiveNumber"

                UniqueName="ArchiveNumber">

                <ItemTemplate>

                    <asp:HyperLink ID="ArchiveNumHyperLink" runat="server" Font-Bold="true"

                        Text="<%# ((ArchiveView)Container.DataItem).ArchiveNumber %>"

                        Visible="false" />

                    <asp:Label ID="ArchiveNumLabel" runat="server" Text="<%# ((ArchiveView)Container.DataItem).ArchiveNumber %>"

                        Visible="false" />

                </ItemTemplate>

            </telerik:GridTemplateColumn>           

            <telerik:GridBoundColumn DataField="SubmissionStatusText" HeaderText="Status" HeaderStyle-Width="80px"

                HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" SortExpression="SubmissionStatusText" ItemStyle-HorizontalAlign="Left"

                UniqueName="SubmissionStatusText" />

                                <telerik:GridBoundColumn DataField="ReportingEntity" HeaderStyle-Width="120px" HeaderText="Reporting<br/>Entity" ItemStyle-HorizontalAlign="Left"

                HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" SortExpression="ReportingEntity"

                UniqueName="ReportingEntity" />

            <telerik:GridBoundColumn DataField="WBSLevelOneNumber" HeaderText="WBS<br/>Level 1<br />Number"

                HeaderStyle-Width="80px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom"

                ItemStyle-HorizontalAlign="Center" SortExpression="WBSLevelOneNumber" UniqueName="WBSLevelOneNumber" />

 

            <telerik:GridBoundColumn DataField="WBSLevelOneName" HeaderText="WBS<br/>Level 1 Name"

                HeaderStyle-Width="105px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom"

                SortExpression="WBSLevelOneName" UniqueName="WBSLevelOneName" />

 

            <telerik:GridTemplateColumn HeaderText="Archive<br />Description" HeaderStyle-Width="140px"

                HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" ItemStyle-HorizontalAlign="Left"

                SortExpression="ArchiveDescription" UniqueName="ArchiveDescription">

                <ItemTemplate>

                    <asp:Label ID="ArchiveDescriptionLabel" runat="server" Text="<%# ((((ArchiveView)Container.DataItem).ArchiveAdditionalDescription ?? String.Empty).Trim()).Trim() %>" />

                </ItemTemplate>

            </telerik:GridTemplateColumn>

               

            <telerik:GridBoundColumn DataField="EngagementDescription" HeaderText="Engagement<br />Description"

                HeaderStyle-Width="140px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" ItemStyle-HorizontalAlign="Left"

                SortExpression="EngagementDescription" UniqueName="EngagementDescription" />

               

            <telerik:GridBoundColumn DataField="YearEnd" HeaderText="Period<br/>End" DataFormatString="{0:MM'/'dd'/'yyyy}"

                HeaderStyle-Width="75px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom"

                SortExpression="YearEnd" UniqueName="YearEnd" />           

            <telerik:GridTemplateColumn DataField="ArchivePartnerDisplayName" HeaderText="Archive<br />Partner"

                HeaderStyle-Width="110px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" ItemStyle-HorizontalAlign="Left"

                SortExpression="ArchivePartnerDisplayName" UniqueName="ArchivePartnerDisplayName" >

                <ItemTemplate>

                    <asp:Label ID="ArchivePartnerLabel" runat="server"

                        Enabled="<%# IsArchiveAvailable((ArchiveView)Container.DataItem)

                                    && !IsArchivePartnerExpired((ArchiveView)Container.DataItem) %>"

                        Text="<%# ((ArchiveView)Container.DataItem).ArchivePartnerDisplayName %>" />&nbsp;

                </ItemTemplate>    

                </telerik:GridTemplateColumn>

            <telerik:GridTemplateColumn DataField="ArchiveManagerDisplayName" HeaderText="Archive<br />Manager"

                HeaderStyle-Width="110px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" ItemStyle-HorizontalAlign="Left"

                SortExpression="ArchiveManagerDisplayName" UniqueName="ArchiveManagerDisplayName" >

                <ItemTemplate>

                    <asp:Label ID="ArchiveManagerLabel" runat="server"

                        Enabled="<%# IsArchiveAvailable((ArchiveView)Container.DataItem)

                                    && !IsArchiveManagerExpired((ArchiveView)Container.DataItem) %>"

                        Text="<%# ((ArchiveView)Container.DataItem).ArchiveManagerDisplayName %>" />&nbsp;

                </ItemTemplate> 

               </telerik:GridTemplateColumn>

            <telerik:GridTemplateColumn DataField="ArchiveFieldSeniorDisplayName" HeaderText="Archive Field<br/>Senior"

                HeaderStyle-Width="110px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" ItemStyle-HorizontalAlign="Left"

                SortExpression="ArchiveFieldSeniorDisplayName" UniqueName="ArchiveFieldSeniorDisplayName">

             <ItemTemplate>

                    <asp:Label ID="ArchiveFieldSeniorLabel" runat="server"

                        Enabled="<%# IsArchiveAvailable((ArchiveView)Container.DataItem)

                                    && !IsArchiveFieldSeniorExpired((ArchiveView)Container.DataItem) %>"

                        Text="<%# ((ArchiveView)Container.DataItem).ArchiveFieldSeniorDisplayName %>" />&nbsp;

                </ItemTemplate>

              </telerik:GridTemplateColumn>

             <telerik:GridTemplateColumn DataField="AdditionalArchiveFieldSeniorDisplayName" HeaderText="Additional<br/>Archive Field<br/>Senior"

                HeaderStyle-Width="110px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" ItemStyle-HorizontalAlign="Left"

                SortExpression="AdditionalArchiveFieldSeniorDisplayName" UniqueName="AdditionalArchiveFieldSeniorDisplayName">

             <ItemTemplate>

                    <asp:Label ID="AdditionalArchiveFieldSeniorDisplayNameLabel" runat="server"

                        Enabled="<%# IsArchiveAvailable((ArchiveView)Container.DataItem)

                                    && !IsAdditionalArchiveFieldSeniorExpired((ArchiveView)Container.DataItem) %>"

                        Text="<%# ((ArchiveView)Container.DataItem).AdditionalArchiveFieldSeniorDisplayName %>" />&nbsp;

                </ItemTemplate>

              </telerik:GridTemplateColumn>

        </Columns>

    </MasterTableView>

    <PagerStyle Position="TopAndBottom" Mode="NextPrevNumericAndAdvanced" />

    <ClientSettings>

 

        <Scrolling AllowScroll="true" FrozenColumnsCount="4" SaveScrollPosition="true" UseStaticHeaders="true" /> 

            <ClientEvents OnGridCreated="AdjustMyArchivesGrid" />

    </ClientSettings>

</telerik:RadGrid>

 

 



Code behind :

using System;

using System.Collections.Generic;

using System.Web.UI.WebControls;

using Deloitte.WAU.BusinessEntities;

using Deloitte.WAU.BusinessEntities.Archive;

using Deloitte.WAU.BusinessEntities.User;

using Telerik.Web.UI;

using Deloitte.WAU.DataAccess;

using Deloitte.WAU.Services.Common;

 

namespace Deloitte.WAU.Site.UserControls

{

    public partial class ArchivesList : System.Web.UI.UserControl

    {

        /// <summary>

        /// Raised on RadGrid's NeedDataSource event to signalized a datasource must be bound to the control

        /// </summary>

        public event EventHandler<GridNeedDataSourceEventArgs> NeedDataSource;

        private readonly Dictionary<int, DispositionType?> _archiveAccessRequestsCache = new Dictionary<int, DispositionType?>();

 

        #region properties

 

        public Boolean IsArchiveNumberHyperLink

        {

            private get { return (bool)(ViewState["IsArchiveNumberHyperLink"] ?? true); }

            set { ViewState["IsArchiveNumberHyperLink"] = value; }

        }

 

        /// <summary>

        /// Gets or sets a datasource for the grid representing a collection of type IEnumerable&lt;ArchiveView&gt;

        /// </summary>

        public IEnumerable<ArchiveView> DataSource

        {

            get { return ArchiveListRadGrid.DataSource as IEnumerable<ArchiveView>; }

            set { ArchiveListRadGrid.DataSource = value; }

        }

 

        /// <summary>

        /// Gets or sets a number of records to display in the grid when paging is enabled. Default is 20

        /// </summary>

        public int PageSize

        {

            get { return ArchiveListRadGrid.PageSize; }

            set { ArchiveListRadGrid.PageSize = value; }

        }

 

        /// <summary>

        /// Get an instance of the GridSortExpressionCollection class representing sorting expression for the grid's

        /// MasterView table

        /// </summary>

        public GridSortExpressionCollection SortExpressions

        {

            get { return ArchiveListRadGrid.MasterTableView.SortExpressions; }

        }

 

        /// <summary>

        /// Gets or sets a number of records in the datasource. Used for custom paging

        /// </summary>

        public int ItemCount

        {

            get { return ArchiveListRadGrid.VirtualItemCount; }

            set { ArchiveListRadGrid.VirtualItemCount = value; }

        }

 

        #endregion

 

        #region methods

 

        /// <summary>

        /// Refreshes the grid content by rebinding the grid and setting CurrentPageIndex to 0

        /// </summary>

        public void Refresh()

        {

            ArchiveListRadGrid.CurrentPageIndex = 0;

            ArchiveListRadGrid.Rebind();

        }

 

        protected void ArchiveListRadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)

        {

            RaiseNeedDataSourceEvent(source, e);

        }

 

        protected void ArchiveListRadGrid_ItemDataBound(object sender, GridItemEventArgs e)

        {

            var gridDataItem = e.Item as GridDataItem;

            if (gridDataItem == null)

            {

                return;

            }

 

            var archiveView = gridDataItem.DataItem as ArchiveView;           

            if (IsArchiveNumberHyperLink && archiveView != null)

            {

                var archivePageLink = gridDataItem.FindControl("ArchiveNumHyperLink") as HyperLink;

                if (archivePageLink != null)

                {

                    var isGetApprovedArchive = archiveView.SubmissionStatus.HasValue

                                                   ? (archiveView.SubmissionStatus.Value.IsApproved() || archiveView.SubmissionStatus.Value.IsApprovedAndResubmitInitiated())

                                                   : false;

                    archivePageLink.NavigateUrl = PageURLHelper.GetArchiveHomePageUrl(archiveView.ArchiveID, isGetApprovedArchive);

                    archivePageLink.Visible = true;

                }

            }

            else

            {

                var archiveNumLabel = gridDataItem.FindControl("ArchiveNumLabel") as Label;

                if (archiveNumLabel != null)

                {

                    archiveNumLabel.Visible = true;

                }

            }

        }

 

        protected void ArchiveListRadGridSortCommand(object source, GridSortCommandEventArgs e)

        {

            var sortExpressions = ArchiveListRadGrid.MasterTableView.SortExpressions;

            var newOrder = e.NewSortOrder;

            sortExpressions.Clear();

            e.Canceled = true;

 

            var newExpression = new GridSortExpression { FieldName = e.SortExpression, SortOrder = newOrder };

            sortExpressions.Add(newExpression);

 

            ArchiveListRadGrid.MasterTableView.Rebind();

        }

 

        private void RaiseNeedDataSourceEvent(object source, GridNeedDataSourceEventArgs e)

        {

            if (NeedDataSource != null)

            {

                NeedDataSource(source, e);

            }

        }

        protected bool IsArchiveAvailable(ArchiveView archiveView)

        {

            return UserCanViewArchive(archiveView) || UserCanRequestAccess(archiveView);

        }

 

        protected bool IsArchivePartnerExpired(ArchiveView archiveView)

        {

            return archiveView.IsArchivePartnerExpired;

        }

 

        protected bool IsArchiveManagerExpired(ArchiveView archiveView)

        {

            return archiveView.IsArchiveManagerExpired;

        }

 

        protected bool IsArchiveFieldSeniorExpired(ArchiveView archiveView)

        {

            return archiveView.IsArchiveFieldSeniorExpired;

        }

 

        protected bool IsAdditionalArchiveFieldSeniorExpired(ArchiveView archiveView)

        {

            return archiveView.IsAdditionalArchiveFieldSeniorExpired;

        }

 

        protected bool UserCanRequestAccess(ArchiveView archiveView)

        {

            return (!UserCanViewArchive(archiveView)

                && IsOfApprovedOrResubmittedApprovedStatus(archiveView.SubmissionStatus));

        }

 

        private bool IsUserHasAcceptedRequestAccess(int archiveId)

        {

            return GetArchiveRequestAccess(archiveId).GetValueOrDefault(DispositionType.Closed) == DispositionType.Accepted;

        }

 

        private static bool IsOfApprovedOrResubmittedApprovedStatus(SubmissionStatus? submissionStatus)

        {

            if (!submissionStatus.HasValue)

            {

                return false;

            }

            return submissionStatus.Value.IsApprovedOrResubmitInitiated();

        }

        private readonly Dictionary<int, bool> _userCanViewArchiveCache = new Dictionary<int, bool>();

 

        protected bool UserCanViewArchive(ArchiveView archiveView)

        {

            if (!_userCanViewArchiveCache.ContainsKey(archiveView.ArchiveID))

            {

                var allowed = ((BasePage)Page).LoggedInEmployee.IsSecurityFunctionAllowed(archiveView, SecurityFunction.RetrievingArchive);

                allowed = allowed || IsUserHasAcceptedRequestAccess(archiveView.ArchiveID);

                _userCanViewArchiveCache.Add(archiveView.ArchiveID, allowed);

            }

            return _userCanViewArchiveCache[archiveView.ArchiveID];

        }

 

        protected DispositionType? GetArchiveRequestAccess(int archiveId)

        {

            if (!_archiveAccessRequestsCache.ContainsKey(archiveId))

            {

                var dispositionType = ServiceFactory.UserService.GetDispositionType(archiveId, SessionManager.CurrentUserId);

                _archiveAccessRequestsCache.Add(archiveId, dispositionType);

            }

            return _archiveAccessRequestsCache[archiveId];

        }

 

        #endregion

    }

}

 

0
Pavlina
Telerik team
answered on 21 Jan 2013, 03:19 PM
Hello,

I tried to replicate the problem you are facing locally, but to no avail. Therefore, I will ask you to provide a live url where this issue can be observed, so we can inspect it locally and advice you further. Also specify which is the browser you use for testing.

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Mithun Pentuker
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Mithun Pentuker
Top achievements
Rank 1
Share this question
or