Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ext JS 4 Plugin and Extension Development

You're reading from   Ext JS 4 Plugin and Extension Development This book makes it fast and fun for ExtJS developers to get to grips with developing plugins and extensions. The step-by-step instructions, with plentiful examples and code, will give you the skills in no time.

Arrow left icon
Product type Paperback
Published in Sep 2013
Publisher Packt
ISBN-13 9781782163725
Length 116 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Abdullah Al Mohammad Abdullah Al Mohammad
Author Profile Icon Abdullah Al Mohammad
Abdullah Al Mohammad
Arrow right icon
View More author details
Toc

Planning and coding the labeled spinner


To meet the functional requirements, we will create an extension class by extending the Ext JS's Ext.form.field.Spinner class from which we will get most of the facilities that we need to provide. We need to implement the onSpinUp and onSpinDown functions of the Ext.form.field.Spinner class to handle the spinner button click event to provide our logic to increase or decrease the values. By default, pressing the up and down arrow keys will also trigger the onSpinUp and onSpinDown methods. Now, let us start coding:

Ext.define('Examples.ux.LabeledSpinner', {
  extend : 'Ext.form.field.Spinner',
  alias : 'widget.labeledspinner',

  onSpinUp : function() {
    this.setValue(++this.value);
  },

  onSpinDown : function() {
    this.setValue(--this.value);
  }
});

And now we have a working extension that can increase or decrease its value. Here is the screenshot where we used this extension:

You can see that we now have a field with up/down spinner buttons...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image