1. #1
    Sencha User
    Join Date
    Nov 2009
    Posts
    93
    Vote Rating
    0
    roshniblr is on a distinguished road

      0  

    Default Unanswered: Using Ext.define in 4

    Unanswered: Using Ext.define in 4


    Hi,

    Recently I have moved to Extjs 4. I was using Ext.extend in 3.X.
    Currently I have re written my like this:

    Ext.onReady(function(){
    Ext.define(Ext.my.Calendar, {
    extend: 'Ext.form.field.Date',
    alias: 'widget.datefield'

    });

    var datefield_Calendar=Ext.create('Ext.my.Calendar', {
    renderTo:'calendarDate',
    allowBlank:false,
    startWithCurrentDate:false,
    name:'date',
    value:'',
    format:'m/d/Y',
    preventMark:true,
    id: 'datefield'
    });

    });

    But this is not working.

  2. #2
    Sencha User
    Join Date
    Sep 2009
    Posts
    85
    Answers
    8
    Vote Rating
    -1
    raz0r1 is an unknown quantity at this point

      0  

    Default


    Hi,
    for my it's working with nearly exactly your code.
    - you have to put the name of your self defined class in '

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <link rel="stylesheet" href="extjs/resources/css/ext-all.css" />
    <script type="text/javascript" src="extjs/ext-all-debug.js"></script>
    <script type="text/javascript">
    Ext.onReady(function(){
    Ext.define('Ext.my.Calendar', { 
    extend: 'Ext.form.field.Date',
    alias: 'widget.datefield'
    
    
    });
    
    
    var datefield_Calendar=Ext.create('Ext.my.Calendar', {
    renderTo:'calendarDate',
    allowBlank:false,
    startWithCurrentDate:false,
    name:'date',
    value:'',
    format:'m/d/Y',
    preventMark:true,
    id: 'datefield'
    });
    
    
    });</script>
    </head>
    <body></body>
    </html>
    If you use ext-debug.js instead of ext-all-debug.js you haft to add "Ext.require('Ext.form.field.Date);" before you use it.

    I would also add
    Code:
    initComponent: function() {
    this.callParent(arguments);
    }
    to your definition of Ext.my.Calender.

    I hope that helps.

  3. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,603
    Answers
    543
    Vote Rating
    325
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    @roshniblr, please use code tags when posting code (# button on the editor toolbar).

    raz0r1 is correct that Ext.define() takes a string as its first argument. However, I don't understand the comment about initComponent. If all you do is callParent() then it's effectively not doing anything. Only add it if you need it.

  4. #4
    Sencha User
    Join Date
    Sep 2009
    Posts
    85
    Answers
    8
    Vote Rating
    -1
    raz0r1 is an unknown quantity at this point

      0  

    Default


    Quote Originally Posted by skirtle View Post
    @roshniblr, please use code tags when posting code (# button on the editor toolbar).

    raz0r1 is correct that Ext.define() takes a string as its first argument. However, I don't understand the comment about initComponent. If all you do is callParent() then it's effectively not doing anything. Only add it if you need it.
    yes you are right but sometimes a had issues when not adding callParent(). So now I add it always only to be sure

Thread Participants: 2