-
5 Oct 2009 6:25 AM #1Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
TabPanel tab title editor
TabPanel tab title editor
Here is a small plugin that allows inline editing of the titles of the panels in a TabPanel on dblclick.
Usage example:Code:Ext.ns('Ext.ux'); Ext.ux.TabTitleEditor = Ext.extend(Object, { init: function(c){ c.on({ render: this.onRender, destroy: this.onDestroy, single: true }); }, onRender: function(c){ c.titleEditor = new Ext.Editor(new Ext.form.TextField({ allowBlank: false, enterIsSpecial: true }), { autoSize: 'width', completeOnEnter: true, cancelOnEsc: true, listeners: { complete: function(editor, value){ var item = this.getComponent(editor.boundEl.id.split(this.idDelimiter)[1]); item.setTitle(value); }, scope: this } }); c.mon(c.strip, { dblclick: function(e){ var t = this.findTargets(e); if(t && t.item && !t.close && t.item.titleEditable !== false){ this.titleEditor.startEdit(t.el, t.item.title); } }, scope: c }); }, onDestroy: function(c){ if(c.titleEditor){ c.titleEditor.destroy(); delete c.titleEditor; } } }); Ext.preg('tabtitleedit', Ext.ux.TabTitleEditor);
Code:new Ext.TabPanel({ height: 200, width: 300, activeTab: 0, items: [{ title: 'Tab 1' },{ title: 'Tab 2' },{ title: 'Tab 3' }], plugins: ['tabtitleedit'], renderTo: Ext.getBody() });Last edited by Condor; 5 Oct 2009 at 6:32 AM. Reason: Added titleEditable config option for panels
-
5 Oct 2009 6:28 AM #2Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
What if I only want some tab titles editable?
SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
5 Oct 2009 6:33 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
I added a titleEditable config option for panels that you can set to 'false' to make the title of the panel uneditable.
-
5 Oct 2009 6:48 AM #4Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
5 Oct 2009 7:57 AM #5
-
5 Oct 2009 10:14 AM #6
-
6 Oct 2009 12:38 AM #7
Thinking about it from different angles, that's a good question. I've got a case here where it's really handy (I've got to differentiate between 'normal' title changes and title edits), but that's probably not something occurring very often and that can be added with a simple createSequence and another complete listener.
-
14 Dec 2009 6:57 PM #8Sencha - Sales Team
- Join Date
- Mar 2007
- Location
- Melbourne, Australia (aka GMT+10)
- Posts
- 738
- Vote Rating
- 6
nice
Check out SenchaWorld.com for articles, screencasts, conference videos and more.
Sencha Technical Training : Asia Pacific Region
Code Validation : JSLint | JSONLint | JSONPLint
-
9 Feb 2010 8:07 AM #9Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
Is there a way to initiate the editing via code and not just the dbl click? I'd like to add a tab and have it automatically start the editing. I tried using the startEdit() function and it would add the textarea but as an item to the tab panel not the tab title.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
9 Feb 2010 8:23 AM #10
The dblclick handling function needs to be broken out and poked into the host TabPanel as the property editTitle.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642


Reply With Quote



