grid panel extension problem

  1. #1

    grid panel extension problem

    
      [Xtype("multigroupgridpanel")]
        [InstanceOf(ClassName = "Ext.ux.MultiGroupingPanel")]
        [ClientScript(Type = typeof(MultiGroupingPanel), FilePath = "/ux/extensions/multigrouping/multigrouping.js", WebResource = "Coolite.Ext.Web.Build.Resources.Coolite.ux.extensions.multigrouping.multigrouping.js")]
        [Designer(typeof(EmptyDesigner))]
        public class MultiGroupingPanel : GridPanel
        {
            protected override void OnBeforeClientInit(Observable sender)
            {
                base.OnBeforeClientInit(sender);
                this.CheckColumns();
                if (this.SelectionMemoryProxy && string.IsNullOrEmpty(this.MemoryIDField) && !string.IsNullOrEmpty(this.StoreID))
                {
                    Store store = ControlUtils.FindControl(this, this.StoreID) as Store;
    
                    if (store != null && store.Reader.Count > 0)
                    {
                        string id = store.Reader.Reader.ReaderID;
                        if (!string.IsNullOrEmpty(id))
                        {
                            this.MemoryIDField = id;
                        }
                    }
                }
            }
    
            private void CheckColumns()
            {
                string plugins = this.GetColumnPlugins();
    
                if (plugins.Length > 2)
                {
                    this.CustomConfig.Add(new ConfigItem("columnPlugins", plugins, ParameterMode.Raw));
                }
            }
    
            private string GetColumnPlugins()
            {
                StringBuilder sb = new StringBuilder("[");
                for (int i = 0; i < this.ColumnModel.Columns.Count; i++)
                {
                    CommandColumn cmdCol = this.ColumnModel.Columns[i] as CommandColumn;
                    ImageCommandColumn imgCmdCol = this.ColumnModel.Columns[i] as ImageCommandColumn;
                    Column column = this.ColumnModel.Columns[i] as Column;
    
                    if (column != null &amp;&amp; column.Commands.Count > 0 &amp;&amp; imgCmdCol == null)
                    {
                        this.ScriptManager.RegisterClientStyleInclude("Coolite.Ext.Web.Build.Resources.Coolite.ux.plugins.commandcolumn.commandcolumn.css");
                        continue;
                    }
    
                    if (cmdCol != null || imgCmdCol != null)
                    {
                        sb.Append(i + ",");
                        this.ScriptManager.RegisterClientStyleInclude("Coolite.Ext.Web.Build.Resources.Coolite.ux.plugins.commandcolumn.commandcolumn.css");
                        continue;
                    }
    
                    CheckColumn cc = this.ColumnModel.Columns[i] as CheckColumn;
    
                    if (cc != null &amp;&amp; cc.Editable)
                    {
                        sb.Append(i + ",");
                        continue;
                    }
                }
    
                if (sb[sb.Length - 1] == ',')
                {
                    sb.Remove(sb.Length - 1, 1);
                }
    
                sb.Append("]");
                return sb.ToString();
            }
    
            protected override void OnAfterClientInit(Observable sender)
            {
                base.OnAfterClientInit(sender);
    
                CheckAutoExpand();
            }
    
            private void CheckAutoExpand()
            {
                if (!string.IsNullOrEmpty(this.AutoExpandColumn))
                {
                    bool found = false;
                    foreach (ColumnBase column in this.ColumnModel.Columns)
                    {
                        if (column.ColumnID == this.AutoExpandColumn)
                        {
                            found = true;
                            break;
                        }
                    }
    
                    if (!found)
                    {
                        throw new ArgumentException(string.Concat("The auto expand Column with ID='", this.AutoExpandColumn, "' is not found!"));
                    }
                }
            }
    
    
            protected override void PageLoadComplete(object sender, EventArgs e)
            {
                base.PageLoadComplete(sender, e);
    
                //Here is we must add view templates because InnerObservable incorrect hosts inner controls
                if (this.View.View != null)
                {
                    this.Controls.Add(this.View.View.Templates.Header);
                }
            }
    
            protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
            {
                bool result = base.LoadPostData(postDataKey, postCollection);
                string val = postCollection[string.Concat(this.ClientID, "_SM")];
    
                if (val != null &amp;&amp; this.SelectionModel.Primary != null)
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.MissingMemberHandling = MissingMemberHandling.Ignore;
                    StringReader sr = new StringReader(val);
    
                    if (this.SelectionModel.Primary is RowSelectionModel)
                    {
                        SelectedRowCollection ids = (SelectedRowCollection)serializer.Deserialize(sr, typeof(SelectedRowCollection));
                        (this.SelectionModel.Primary as RowSelectionModel).SetSelection(ids);
                    }
                    else if (this.SelectionModel.Primary is CellSelectionModel)
                    {
                        SelectedCellSerializable cell = (SelectedCellSerializable)serializer.Deserialize(sr, typeof(SelectedCellSerializable));
                        if (cell != null)
                        {
                            CellSelectionModel sm = this.SelectionModel.Primary as CellSelectionModel;
                            sm.SelectedCell.RowIndex = cell.RowIndex;
                            sm.SelectedCell.ColIndex = cell.ColIndex;
                            sm.SelectedCell.RecordID = cell.RecordID;
                            sm.SelectedCell.Name = cell.Name;
                            sm.SelectedCell.Value = cell.Value;
                        }
                    }
                }
    
                return result;
            }
        }

    i have this multigrouping grid panel which allows for multiple grouping in a grid panel... my problem now is that i cannot get the selectedRows of its selection model... if you will check the selectionmodel collection of the grid panel, there is selectionmodel item, but the problem is if i do selectionModel..SelectedRows... it is always empty even if i have a row selected... please help
  2. #2

    RE: grid panel extension problem

    problem solved... instead of extend Ext.grid.GridPanel for the Ext.ux.MultiGroupingPanel js version... Coolite.Ext.GridPanel should be used

    
    multigrouping.js
    
    
    Ext.ux.MultiGroupingPanel = function(config) {
        config = config||{};
        //removed this part to prevent grouping column topbar
        //config.tbar = new Ext.Toolbar({id:'grid-tbr'});
        //removed this part to prevent grouping column topbar
        Ext.ux.MultiGroupingPanel.superclass.constructor.call(this, config);
    };
    
    Ext.extend(Ext.ux.MultiGroupingPanel, Coolite.Ext.GridPanel, {
        initComponent : function(){
            Ext.ux.MultiGroupingPanel.superclass.initComponent.call(this);
            //this.on("render", this.setUpDragging, this);
        }

Similar Threads

  1. grid Panel problem
    By Egale in forum 1.x Help
    Replies: 0
    Last Post: Jun 22, 2011, 11:26 AM
  2. problem with grid panel
    By anuar in forum 1.x Help
    Replies: 1
    Last Post: Jan 25, 2011, 9:22 AM
  3. Problem With Grid Panel in Extjs
    By a_elsayed2010 in forum 1.x Help
    Replies: 2
    Last Post: Sep 29, 2010, 1:48 PM
  4. [CLOSED] Problem in Hiding Row Grid Panel
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 12, 2010, 2:09 PM
  5. Problem with updating grid panel
    By Nagaraj K Hebbar in forum 1.x Help
    Replies: 0
    Last Post: May 09, 2009, 12:52 PM

Posting Permissions