New Plugin

  1. #1

    New Plugin

    Hi,
    I
    downloaded the Coolite.ux.InputMask and me interested in creating a
    plugin to edit values (R$ 324.55 for example). Following the model
    of InputMask tutorial and the link:
    http://extjs.com/learn/Manual:Intro:Inheritance.
    I started a plugin MyCurrency as the code below to test.

    MyCurrency.cs
    
    /******** 
    * Copyright (c) 2008 Coolite Inc.
    
    * Permission is hereby granted, free of charge, to any person obtaining a copy
    * of this software and associated documentation files (the "Software"), to deal
    * in the Software without restriction, including without limitation the rights
    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    * copies of the Software, and to permit persons to whom the Software is
    * furnished to do so, subject to the following conditions:
    
    * The above copyright notice and this permission notice shall be included in
    * all copies or substantial portions of the Software.
    
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    * THE SOFTWARE.
    
    * @version:        0.7.0
    * @author:        Coolite Inc. http://www.ext.net/
    * @date:        2008-11-21
    * @copyright:   Copyright (c) 2006-2008, Coolite Inc, or as noted within each 
    *                 applicable file LICENSE.txt file
    * @license:        MIT
    * @website:        http://www.ext.net/
    ********/
    
    using System.ComponentModel;
    using System.Web.UI;
    using Coolite.Ext.Web;
    using System.Drawing;
    
    namespace Coolite.Ext.UX
    {
        /*
         * MyCurrency
        */
    
        [InstanceOf(ClassName = "Ext.ux.netbox.MyCurrency")]
        [ClientScript(Type = typeof(MyCurrency), WebResource = "Coolite.Ext.UX.Plugins.MyCurrency.resources.MyCurrency.js")]
        [ToolboxBitmap(typeof(Coolite.Ext.UX.MyCurrency), "Build.Resources.ToolboxIcons.Plugin.bmp")]
        [ToolboxData("<{0}:MyCurrency runat=\"server\" />")]
        [Description("MyCurrency plugin used for mask/regexp operations")]
        public class MyCurrency : Plugin
        {
            [ClientConfig]
            [Category("Config Options")]
            [DefaultValue("")]
            [NotifyParentProperty(true)]
            [Description("The MyCurrency")]
            public string Simbol
            {
                get
                {
                    object obj = this.ViewState["Simbol"];
                    return obj == null ? "" : (string)obj;
                }
                set
                {
                    this.ViewState["Simbol"] = value;
                }
            }
    
        }
    }
    MyCurrency.js
    
    Ext.namespace('Ext.ux.netbox');
    /*
     * MyCurrency
     *
    */
    Ext.ux.netbox.MyCurrency = function(simbol) {
        var simb = simb.Simbol;
    };
    Ext.extend(Ext.ux.netbox.MyCurrency, Ext.form.TextField, {
        theDocument: Ext.get(document),
        myCurrencyFn1: function() {
            // etc.
        },
        myCurrencyFn2: function() {
            // etc.
        }
    });
    Ext.ux.MyCurrency = Ext.ux.netbox.MyCurrency;
    I put the plugin on the page and run the error occurs:

    Ext.ux.netbox.MyCurrency is not a constructor


    Any tips?
    Thank you.
    Maia.


  2. #2

    RE: New Plugin

    Hi Maia,

    Can you confirm that the .js file loads on initial page_load?




    Geoffrey McGill
    Founder
  3. #3

    RE: New Plugin

    Hi,
    I just registered the assembly, as did the InputMask.

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FrmProspect.ascx.cs" Inherits="CRMWeb.View.frmProspect" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <%@ Register Assembly="Coolite.Ext.UX" Namespace="Coolite.Ext.UX" TagPrefix="ux" %>




  4. #4

    RE: New Plugin

    Any Help?
  5. #5

    RE: New Plugin

    Hello Maia

    First: Your plugin is extending Ext.form.textfield? Why? It's a plugin or a sub-class?

    Try see better full code of InputMask (http://code.google.com/p/cherryonext...putTextMask.js).

    Second question:

    Try something like

    Ext.ux.netbox.MyCurrency = function(simbol) {
        var simb = simb.Simbol;
    };
    
    Ext.ux.netbox.MyCurrency.prototype = {
        fn1: function(){},
        fn2: function(arg1, arg2){}
    };//Finally
    Ext.ux.MyCurrency = Ext.ux.netbox.MyCurrency;

    Third:

    If you plan extend coolite (c# and javascript) components, some modifications are needed:

    Please verify the topic http://forums.ext.net/showthread.php...15147-7-1.aspx

Similar Threads

  1. [CLOSED] Plugin
    By boris in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 23, 2011, 1:10 PM
  2. 1.0 generic plugin
    By [WP]joju in forum 1.x Help
    Replies: 7
    Last Post: Dec 07, 2009, 12:37 PM
  3. Plugin in GridPanel
    By olimpia in forum 1.x Help
    Replies: 0
    Last Post: Jul 14, 2009, 9:51 PM

Posting Permissions