Results 1 to 2 of 2

Thread: [best practice] sencha component vs plain js based code when using sencha

  1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    448

    Question [best practice] sencha component vs plain js based code when using sencha

    hi all;
    so I am just starting to get the hang of sencha.
    a few days ago I needed to display ticker like data with each item in the data is displayed for a period of time and after that period the next item would appear.
    using sencha I thought to my self that a carousel would fit here because each card can be an item so I implemented a 'self rotating' carousel that way.
    after the job was finished I thought to myself that for this task i could have just use plain JS/CSS/DOM manipulation to rotate the items inside a simple panel - no need for a carousel.
    so my question is: assuming one already uses sencha (for layout, etc...), when is using a sencha component good and when is it overkill?
    thanks

  2. #2
    Sencha User gcallaghan's Avatar
    Join Date
    Apr 2010
    Location
    Cupertino, Ca
    Posts
    247

    Default

    For code consistency and readability I would use sencha components as much as possible. I would also attempt to use the lowest level component I could and extend the custom functionality i needed. For instance in this case, I agree a carousel might be overkill. I would extend the Panel class, configure it with a card layout, ad a rotate method that would automatically set the active card. soemthing like...

    Code:
    MyPanel = Ext.extend(Ext.Panel,{
       layout:card,
       items:[
          {html:'html1'},
          {html:'html2'},
          {html:'html3'},
          {html:'html4'},
          {html:'html5'},
          ....
          {html:'htmlN'},
       ],
       interval:500,
       intervalId:null,
       rotate:function(){
           
                var next = this.items.indexOf(this.getActiveItem());
                next = next >= this.items.getCount() ? 0 : next;
                this.setActiveItem(next);
                
               
       },
       startRotating:function(){
          this.intervalId = setInterval("this.rotate()",this.interval);
       },
       stopRotating:function(){
          this.clearInterval(this.intervalID);
       }
    })
    I think the biggest gain is maintaining the object oriented architecture and the maintainability that comes with it. Thats my two cents. But am still learning as well.

Similar Threads

  1. Replies: 10
    Last Post: 20 Jan 2012, 10:10 AM
  2. Is Sencha Touch based on Ext JS??
    By zmonster in forum Sencha Touch 1.x: Discussion
    Replies: 10
    Last Post: 30 May 2011, 11:33 AM
  3. A sencha-touch based theme plugin for WordPress: first working alpha
    By sandro.paganotti in forum Sencha Touch 1.x: Examples and Showcases
    Replies: 4
    Last Post: 4 Sep 2010, 6:15 AM
  4. Do any body have mysql based sencha touch demo
    By sumitgrover in forum Sencha Touch 1.x: Examples and Showcases
    Replies: 5
    Last Post: 25 Aug 2010, 10:19 PM
  5. How to integrate existing code with Sencha
    By ssdesign in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 28 Jun 2010, 5:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •