[CLOSED] How to extend Ext.NET components

  1. #1

    [CLOSED] How to extend Ext.NET components

    Hello!

    I have extended class, for example this:

    
    [assembly: WebResource("Core.View.Ext.Scripts.pagingRecalc.js", "text/javascript")]
    namespace Core.View.Ext
    {
        using System;
        using System.Collections.Generic;
       
    using System.Web.UI;
        using global::Ext.Net;  
    
        public class UniversalGrid : GridPanel
        {
            public UniversalGrid(string sysName, ComponentDirectEvent.DirectEventHandler eventHandler)
            {           
                EntityTipeInfo = Domain.Current.Model.Types[sysName];
                EntityName = sysName;
                Frame = false;
                Layout = "fit";
                LoadMask.ShowMask = false;
                // .... etc
    
                if (!store.AutoLoad)
               { 
                  Listeners.AfterLayout.Fn = "pagingRecalc";
                   Listeners.AfterLayout.Single = true;
                }
            }
    
            protected override List<ResourceItem> Resources
            {
                get
                {
                    List<ResourceItem> baseList = base.Resources;
                    baseList.Capacity += 1;
                    baseList.Add(new ClientScriptItem(typeof(UniversalGrid),
                        "Core.View.Ext.Scripts.pagingRecalc.js",
                        @"Core.View.Ext\Scripts\pagingRecalc.js"
                        ));
    
                    return baseList;
                }
            }
        }
    }
    I would need often extend base classes, and I want do it nice. Here I added only one JS file and some pre-init logic. But sometimes I would need add imagis, CSS, and other resources or client and server logic. I interesting how to do it right. Maybe you have some samples, tutorials or clear examples of extending server classes with including client code/resources?

    The main thing that interests me - the
    ideology of extending components in Ext.NET.

    Thanks!
  2. #2

    RE: [CLOSED] How to extend Ext.NET components

    Hi,

    1. If you create control which has new client side instance name (for example, if you extend javascript class) then you need ovveride InstanceOf and XType properties
    public override string InstanceOf
            {
                get
                {
                    return "Ext.ux.tree.TreeGrid";
                }
            }
     public override string XType
            {
                get
                {
                    return "treegrid";
                }
            }
    2. Using Resources properties you can register javascript and css files
    protected override List<ResourceItem> Resources
            {
                get
                {
                    List<ResourceItem> baseList = base.Resources;
                    baseList.Capacity += 2;
    
                    baseList.Add(new ClientScriptItem(typeof(TreeGrid), "Ext.Net.Build.Ext.Net.ux.extensions.treegrid.treegrid.js", "/ux/extensions/treegrid/treegrid.js"));
                    baseList.Add(new ClientStyleItem(typeof(TreeGrid), "Ext.Net.Build.Ext.Net.ux.extensions.treegrid.resources.css.treegrid.css", "/ux/extensions/treegrid/resources/css/treegrid.css"));
    
                    return baseList;
                }
            }
    Images which using in the css must be have the following url format (if you use images as resources)
    .x-grid3-add-row{background:#f9f9f9 url("<%=WebResource("Ext.Net.Build.Ext.Net.ux.extensions.multiheader.images.grid3-hrow.gif")%>") repeat-x left top;cursor:default;zoom:1;padding:1px 0 0 0; height:24px !important;}
    3. All config properties must be added to the ConfigOptions collection
    [Browsable(false)]
            [EditorBrowsable(EditorBrowsableState.Never)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
            [XmlIgnore]
            [JsonIgnore]
            public override ConfigOptionsCollection ConfigOptions
            {
                get
                {
                    ConfigOptionsCollection list = base.ConfigOptions;
                    
                    list.Add("columns", new ConfigOption("columns", new SerializationOptions("columns", JsonMode.AlwaysArray), null, this.Columns ));
                    list.Add("autoScroll", new ConfigOption("autoScroll", new SerializationOptions(JsonMode.Ignore), false, this.AutoScroll ));
                    list.Add("rootVisible", new ConfigOption("rootVisible", null, false, this.RootVisible ));
                    list.Add("useArrows", new ConfigOption("useArrows", null, true, this.UseArrows ));
                    list.Add("lines", new ConfigOption("lines", null, false, this.Lines ));
                    list.Add("columnResize", new ConfigOption("columnResize", null, true, this.ColumnResize ));
                    list.Add("enableSort", new ConfigOption("enableSort", null, true, this.EnableSort ));
                    list.Add("reserveScrollOffset", new ConfigOption("reserveScrollOffset", null, true, this.ReserveScrollOffset ));
                    list.Add("enableHdMenu", new ConfigOption("enableHdMenu", null, true, this.EnableHdMenu ));
                    list.Add("columnsText", new ConfigOption("columnsText", null, "Columns", this.ColumnsText ));
                    list.Add("hideHeaders", new ConfigOption("hideHeaders", null, false, this.HideHeaders ));
                    list.Add("noLeafIcon", new ConfigOption("noLeafIcon", null, false, this.NoLeafIcon ));
    
                    return list;
                }
            }
    P.S. Just see implementation of the any standard Ext.NET control. Any Ext.Net control can be considered as extending

Similar Threads

  1. [CLOSED] Extend timeout for loading a store
    By 78fede78 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 22, 2013, 5:35 AM
  2. Replies: 1
    Last Post: Jun 08, 2012, 10:12 AM
  3. [CLOSED] [MVC] Extend EXT Resources
    By tiramisu in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 29, 2010, 1:32 PM
  4. Extend Gridfilters Remote example with grouping
    By CarWise in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Oct 14, 2010, 12:15 PM
  5. Help for very simple extend gridpanel!Is it a bug?
    By tangcan2003 in forum 1.x Help
    Replies: 3
    Last Post: Nov 18, 2009, 1:00 AM

Tags for this Thread

Posting Permissions