[CLOSED] Any chance of adding frozen columns to GridPanel?

  1. #1

    [CLOSED] Any chance of adding frozen columns to GridPanel?

    One big feature missing from GridPanel is frozen columns. *In most cases, I only want to freeze the first column. *Is there an easy way to accomplish this? *

    There's a potential working extension for it, but I am lost as to how to add it to existing Coolite framework:
    http://extjs.com/forum/showthread.php?t=17942





  2. #2

    RE: [CLOSED] Any chance of adding frozen columns to GridPanel?

    Hi,

    I have looked into this extension. It is independt control (not plugin) . So, if you want to use it then need to implement it as custom control (or use it directly in javascript block).

    Several suggestion for implementing it as custom control:

    1. Create class which can looked as

        [Xtype("lockgrid")]
        [InstanceOf(ClassName = "Ext.grid.LockingGridPanel")]
        [ClientScript(FilePath="/coolite/columnLock.js", WebResource =   "Coolite.Ext.Web.Build.Resources.Coolite.coolite.columnLock.js")]
        [ToolboxData("<{0}: LockingGridPanel runat=\"server\"></{0}: LockingGridPanel >")]
        [Designer(typeof(EmptyDesigner))]
        public class LockingGridPanel: GridPanel
    2. Create LockColumn inherits from Column which has Locked property

    public class LockColumn : Column
    {
      [ClientConfig]
      [DefaultValue(false)]
      [NotifyParentProperty(true)]
      public virtual bool Locked
      {
          get
          {
              object obj = this.ViewState["Locked"];
              return obj == null ? false: (bool)obj;
          }
          set
          {
              this.ViewState["Locked"] = value;
          }
      }

    3. Change client-side class
    - inherits from Coolite.Ext.GridPanel
    - add Ext.reg("lockgrid", Ext.grid.LockingGridPanel); for lazy instantiate
  3. #3

    RE: [CLOSED] Any chance of adding frozen columns to GridPanel?

    I am very close to getting this to work. The only problem I have now is getting Coolite to render Ext.grid.LockingColumnModel instead of Ext.grid.ColumnModel. I created a new serverside LockingColumnModel class that inherits from ColumnModel. However, I can't seem to find a way to set the GridPanel's columnModel variable to it. I can override the ColumnModel property but I can't set the private columnModel variable to my new LockingColumnModel. Even if I create a new private _lockingColumnModel variable in my LockingGridPanel, I can't add a handler to ColumnCollection.AfterItemAdd since that event is internal.

    Serverside GridPanelBase.cs:
            private ColumnModel columnModel;
            public virtual ColumnModel ColumnModel
            {
                get
                {
                    if (this.columnModel == null)
                    {
                        this.columnModel = new ColumnModel();
                        this.columnModel.Columns.AfterItemAdd += Columns_AfterItemAdd;
                    }
                    return this.columnModel;
                }
            }
    Serverside LockingGridPanel.vb:
        Private _lockingColumnModel As ColumnModel
        Public Overrides ReadOnly Property ColumnModel() As Coolite.Ext.Web.ColumnModel
            Get
                If _lockingColumnModel Is Nothing Then
                    _lockingColumnModel = New LockingColumnModel
                    'Can not add handler since both the event and the delegate are private and not accessible...
                    'AddHandler _lockingColumnModel.Columns.AfterItemAdd, AddressOf Columns_AfterItemAdd
                End If
                Return _lockingColumnModel
            End Get
        End Property
  4. #4

    RE: [CLOSED] Any chance of adding frozen columns to GridPanel?

    Hi,

    You can use old ColumnModel. Just modify js code

    Instead:
    Ext.grid.LockingColumnModel = Ext.extend(Ext.grid.ColumnModel,{
        getTotalLockedWidth : function(){
            var totalWidth = 0;
            for(var i = 0; i < this.config.length; i++){
                if(this.isLocked(i) &amp;&amp; !this.isHidden(i)){
                    totalWidth += this.getColumnWidth(i);
                }
            }
            return totalWidth;
        }
    });
    Use:
    Ext.grid.ColumnModel.override({
        getTotalLockedWidth : function(){
            var totalWidth = 0;
            for(var i = 0; i < this.config.length; i++){
                if(this.isLocked(i) &amp;&amp; !this.isHidden(i)){
                    totalWidth += this.getColumnWidth(i);
                }
            }
            return totalWidth;
        }
    });
    And remove any LockingColumnModel reference in js code
  5. #5

    RE: [CLOSED] Any chance of adding frozen columns to GridPanel?

    Thank you. That worked perfectly. Also added override to set Locked:true to RowNumbererColumn.
  6. #6

    RE: [CLOSED] Any chance of adding frozen columns to GridPanel?

    Hi Jchau,

    Could you please reproduce step-by-step what you´ve done to make frozen columns to work, or even post a souce code showing how to do this ?

    I think it´s a "must have" feature that could be very wellcome in the near future versions os coolite´s gridpanel

    Regards

    Fábio

Similar Threads

  1. Replies: 0
    Last Post: Mar 10, 2009, 4:56 AM
  2. [CLOSED] Grid adding removing columns in codebehind
    By methode in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Feb 24, 2009, 2:51 AM
  3. Replies: 1
    Last Post: Jan 29, 2009, 10:46 AM

Posting Permissions