[CLOSED] PagingToolbar plugin ownerCt

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] PagingToolbar plugin ownerCt

    Hi,

    In Ext.NET v1.3 I had a plugin that could be used like this inside a GridPanel or TreePanel

    <BottomBar>
                        <ext:PagingToolbar ID="GruposCalendariosPager" runat="server">
                            <Plugins>
                                <SoftMachine:IndexServerPagingToolbar runat="server" />
                            </Plugins>
                        </ext:PagingToolbar>
                    </BottomBar>
    And this is my plugin code (example):
    Ext.namespace('Ext.ux.netbox');
    
    Ext.ux.netbox.IndexServerPagingToolbar = function (config) {
        //Nothing
    };
    
    Ext.ux.netbox.IndexServerPagingToolbar.prototype = {
        //Instancia del control PagingToolbar
        controlPagingToolbar: null,
    
        init: function (control) {
            if (control.ownerCt.xtype == "netgrid") {
               //Some Code
             }
        }
    };
    Ext.ux.IndexServerPagingToolbar = Ext.ux.netbox.IndexServerPagingToolbar;
    But control.ownerCt is undefined right now. How can I obtain ownerCt to access xtype and other properties?
    Last edited by Daniil; Jun 15, 2012 at 11:52 AM. Reason: [CLOSED]
  2. #2
    Hi,

    It has been changed due to the changes in the widget life cycle. Now its plugins are initialized before it has the ownerCt reference.

    The ownerCt appears when a widget is added to the container. So, I can suggest to use the widget Added listener to initialize the plugin.

    Example
    <ext:PagingToolbar runat="server">
        <Listeners>
            <Added Handler="new Ext.ux.netbox.IndexServerPagingToolbar().init(this);" />
        </Listeners>
    </ext:PagingToolbar>
    Also, please note that we didn't create a separate class for GridPanel in v2, so, this
    control.ownerCt.xtype
    will be "gridpanel" for <ext:GridPanel> as for a common ExtJS grid.
  3. #3
    With this workaround plugin will be initialized two times right?
    And to difference it ownerCt is present in added event, right?
  4. #4
    Quote Originally Posted by softmachine2011 View Post
    With this workaround plugin will be initialized two times right?
    Well, yes, if you will leave Plugins section. But you should remove it in the case when you initialize the plugin within the Added listener.

    Quote Originally Posted by softmachine2011 View Post
    And to difference it ownerCt is present in added event, right?
    Yes, you can access ownerCt within the Added listener.

    Even mode, the container is passed as an argument.
    http://docs.sencha.com/ext-js/4-1/#!...nt-event-added
  5. #5
    Well, removing plugins section Ext.ux.netbox.IndexServerPagingToolbar doesn't exists. How I have to add it? Like a regular JS in a centralized master page or there is another way to load it for plugins?
  6. #6
    I would recommend to check ownerCt in js and if it empty then listen 'added' event

    Something like this (did not test it)
    init: function (control) {
    if (!control.ownerCt) {    control.on("added", this.init, this, {single:true});  
        return; 
     }
    
    
       if (control.ownerCt.xtype == "grid") {
           
       }
    }
    Vladimir Shcheglov
    Sr. Developer
  7. #7
    Agree, it would be more consistent.

    Quote Originally Posted by softmachine2011 View Post
    Well, removing plugins section Ext.ux.netbox.IndexServerPagingToolbar doesn't exists. How I have to add it? Like a regular JS in a centralized master page or there is another way to load it for plugins?
    Yes, just a common JavaScript file.

    Or you even could implement a custom control, here is the example.
    http://forums.ext.net/showthread.php...ll=1#post63023
  8. #8
    The problem is that I have server side code for the control since original version (ext.net v1.3) but removing plugin section, it doesn't initialize the assembly information or maybe it is done after added event. I don't know

    here's my plugin code
    using System.ComponentModel;
    using System.Collections.Generic;
    using System.Web.UI;
    using System.Xml.Serialization;
    using Newtonsoft.Json;
    
    [assembly: WebResource("Softmachine.Millenium.Presentation.Web.MVC.Client.Resources.js.WebControls.IndexServerPagingToolbar.js", "text/javascript")]
    
    namespace Ext.Net
    {
        [ToolboxItem(true)]
        [ToolboxData("<{0}:IndexServerPagingToolbar runat=\"server\" />")]
        [Description("IndexServerPagingToolbar plugin used for index pagination in server-side")]
        public class IndexServerPagingToolbar : Plugin
        {
            /// <summary>
            /// 
            /// </summary>
            [Description("")]
            protected override List<ResourceItem> Resources
            {
                get
                {
                    List<ResourceItem> baseList = base.Resources;
    
                    baseList.Capacity += 1;
    
                    ClientScriptItem _csi = new ClientScriptItem(
                        this.GetType(),
                        "Softmachine.Millenium.Presentation.Web.MVC.Client.Resources.js.WebControls.IndexServerPagingToolbar.js",
                        "/ux/plugins/indexserverpagingtoolbar/indexserverpagingtoolbar.js");
    
                    baseList.Add(_csi);
    
                    return baseList;
                }
            }
    
            /// <summary>
            /// 
            /// </summary>
            [Category("0. About")]
            [Description("")]
            public override string InstanceOf
            {
                get
                {
                    return "Ext.ux.netbox.IndexServerPagingToolbar";
                }
            }
    
            /// <summary>
            /// 
            /// </summary>
            [Browsable(false)]
            [EditorBrowsable(EditorBrowsableState.Never)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
            [XmlIgnore]
            [JsonIgnore]
            public override ConfigOptionsCollection ConfigOptions
            {
                get
                {
                    ConfigOptionsCollection list = base.ConfigOptions;
    
                    return list;
                }
            }
        }
    }
    Any idea?
  9. #9
    Can you see a resource request? What is its URL and response?
  10. #10
    Quote Originally Posted by Daniil View Post
    Can you see a resource request? What is its URL and response?
    No, with developer tools of IE9 in network there isn't any request to this JS, but with plugin section the request is done correctly.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: May 11, 2012, 4:56 PM
  2. [CLOSED] Pagingtoolbar MVC
    By webppl in forum 1.x Premium Help
    Replies: 3
    Last Post: Jun 22, 2011, 9:20 AM
  3. [CLOSED] [1.0] Toolbar Ref not placed in OwnerCt
    By r_honey in forum 1.x Premium Help
    Replies: 2
    Last Post: Apr 23, 2010, 6:52 AM
  4. [CLOSED] PagingToolbar
    By Timothy in forum 1.x Premium Help
    Replies: 3
    Last Post: Dec 29, 2009, 9:47 PM
  5. [CLOSED] PagingToolBar
    By Rod in forum 1.x Help
    Replies: 4
    Last Post: Oct 03, 2008, 8:43 AM

Tags for this Thread

Posting Permissions