[CLOSED] PagingToolbar plugin ownerCt

Page 2 of 2 FirstFirst 12
  1. #11
    Are there any 404 requests?

    The following works on my side.

    CustomPlugin.cs
    using System.Collections.Generic;
    using Ext.Net;
    
    namespace Work2
    {
        public class CustomPlugin : Plugin
        {
            public override string InstanceOf
            {
                get
                {
                    return "Ext.ux.CustomPlugin";
                }
            }
    
            protected override List<ResourceItem> Resources
            {
                get
                {
                    List<ResourceItem> baseList = base.Resources;
    
                    baseList.Capacity += 1;
    
                    ClientScriptItem _csi = new ClientScriptItem(
                        this.GetType(),
                        "Work2.resources.js.CustomPlugin.js",
                        "/resources/js/CustomPlugin.js");
    
                    baseList.Add(_csi);
    
                    return baseList;
                }
            }
        }
    }
    CustomPlugin.js
    Ext.define("Ext.ux.CustomPlugin", {
        extend : "Ext.AbstractPlugin",
        init   : function (c) {
            alert("The plugin has been initialized.");
        }
    });
    AssemblyInfo.cs
    [assembly: WebResource("Work2.resources.js.CustomPlugin.js", "text/javascript")]
    Example Page
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Register Assembly="Work2" Namespace="Work2" TagPrefix="cc" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Panel runat="server">
                <Plugins>
                    <cc:CustomPlugin runat="server" />
                </Plugins>
            </ext:Panel>
        </form>
    </body>
    </html>
    Also I have marked CustomPlugin.js as "Embedded Resource".
  2. #12
    It works too for me, but remember that we are removing plugins section to add the plugin in added event, because I need ownerCt property.

    I paste js code of plugin if you needed

    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 (!Ext.isEmpty(control.ownerCt)) {
                //Obtenemos la instancia del control
                Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar = control;
    
                //Modificamos el comportamiento del boton "refresh"
                if (control.ownerCt.xtype == "netgrid") {
                    //GridPanel
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.refresh.onClick = Ext.ux.netbox.IndexServerPagingToolbar.prototype.refreshFunctionGridPanel;
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.setNavigationVisibility = Ext.ux.netbox.IndexServerPagingToolbar.prototype.setNavigationVisibility;
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.doLoad = Ext.ux.netbox.IndexServerPagingToolbar.prototype.customDoLoad;
                }
                else if (control.ownerCt.xtype == "nettreepanel") {
                    //Ocultamos el input textbox (Los TreePanel no tienen paginacion)
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.inputItem.hide();
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.first.hide();
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.next.hide();
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.prev.hide();
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.last.hide();
    
                    //Ocultamos los separadores
                    for (var i = 0; i < Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items.length - 1; i++) {
                        if (Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].getXType().toString().toLowerCase() == "tbseparator")
                            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].hide();
                    }
    
                    //TreePanel
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.refresh.onClick = Ext.ux.netbox.IndexServerPagingToolbar.prototype.refreshFunctionTreePanel;
                }
                else if (Ext.isEmpty(control.ownerCt.xtype) && control.ownerCt.defaultType == "panel") {
                    //Panel
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.refresh.onClick = Ext.ux.netbox.IndexServerPagingToolbar.prototype.refreshFunctionPanel;
                }
            }
        },
    
        //Funcion que refresca el listado de un GridPanel (Invalidacion de cache)
        refreshFunctionGridPanel: function (e) {
            //Agregamos un parametro base (valor == true)
            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.store.setBaseParam('Refresh', true);
    
            //Funcion onClick de Refresh
            if (e) {
                e.preventDefault();
            }
            if (e.button !== 0) {
                return;
            }
            if (!this.disabled) {
                this.doToggle();
                if (this.menu && !this.hasVisibleMenu() && !this.ignoreNextClick) {
                    this.showMenu();
                }
                this.fireEvent('click', this, e);
                if (this.handler) {
    
                    this.handler.call(this.scope || this, this, e);
                }
            }
    
            //Modificamos el parametro base (valor == false)
            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.store.setBaseParam('Refresh', false);
        },
    
        refreshFunctionTreePanel: function (e) {
            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.ownerCt.loader.baseParams.Refresh = true;
            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.ownerCt.getRootNode().reload();
            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.ownerCt.loader.baseParams.Refresh = null;
        },
    
        refreshFunctionPanel: function (e) {
            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.store.setBaseParam('Refresh', true);
            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.store.reload();
            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.store.setBaseParam('Refresh', false);
        },
    
        customDoLoad: function (start) {
            var o = {}, pn = this.getParams();
            o[pn.start] = start;
            o[pn.limit] = this.pageSize;
            if (this.fireEvent('beforechange', this, o) !== false) {
                this.store.load({ params: o, callback: function () {
                    if (!Ext.isEmpty(this.reader.jsonData.hideNavigation))
                        Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.setNavigationVisibility(this.reader.jsonData.hideNavigation);
                }
                });
            }
        },
    
        setNavigationVisibility: function (isHidden, allowOrderDescending) {
            if (isHidden == true) {
                for (var i = 0; i < Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items.length; i++) {
                    switch (Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].getXType().toString().toLowerCase()) {
                        case 'tbbutton':
                            //Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].setDisabled(false);
                            break;
    
                        case 'tbtext':
                            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].el.dom.style.visibility = 'hidden';
                            break;
    
                        case 'numberfield':
                            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].el.dom.style.visibility = 'hidden';
                            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].setDisabled(true);
                            break;
                    }
                }
            }
            else {
                for (var i = 0; i < Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items.length; i++) {
                    switch (Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].getXType().toString().toLowerCase()) {
                        case 'tbbutton':
                            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].setDisabled(false);
                            break;
    
                        case 'tbtext':
                            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].el.dom.style.visibility = 'visible';
                            break;
    
                        case 'numberfield':
                            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].el.dom.style.visibility = 'visible';
                            Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.items.items[i].setDisabled(false);
                            break;
                    }
                }
    
                var pageData = this.getPageData();
    
                if (pageData.activePage == 1) {
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.first.setDisabled(true);
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.prev.setDisabled(true);
                }
                if (pageData.activePage == pageData.pages) {
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.next.setDisabled(true);
                    Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.last.setDisabled(true);
                }
            }
    
            if (Ext.isEmpty(allowOrderDescending))
                allowOrderDescending = true;
    
            if (Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.ownerCt.view)
                Ext.ux.netbox.IndexServerPagingToolbar.prototype.controlPagingToolbar.ownerCt.view.hmenu.getComponent('desc').setVisible(allowOrderDescending);
        }
    };
    
    Ext.ux.IndexServerPagingToolbar = Ext.ux.netbox.IndexServerPagingToolbar;
  3. #13
    Quote Originally Posted by softmachine2011 View Post
    It works too for me, but remember that we are removing plugins section to add the plugin in added event, because I need ownerCt property.
    If you want the JavaScript file will be registered automatically, you should use that plugin as a custom control within Plugins section.

    In that case please follow the Vladimir's recommendation.
    Quote Originally Posted by Vladimir View Post
    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") {
           
       }
    }
  4. #14
    Ok, I would use Vladimir suggestion.

    Thanks for all
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 5
    Last Post: May 11, 2012, 4:56 PM
  2. [CLOSED] Pagingtoolbar MVC
    By webppl in forum 1.x Legacy 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 Legacy Premium Help
    Replies: 2
    Last Post: Apr 23, 2010, 6:52 AM
  4. [CLOSED] PagingToolbar
    By Timothy in forum 1.x Legacy 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