PDA

View Full Version : Add more buttons to html editor



hieu79vn
22 Aug 2012, 5:03 AM
Hi

Could you tell me how to add more buttons to html editor. And do you have attachment file button in html editor?

Thank you

friend
22 Aug 2012, 5:55 AM
A simple way to add buttons to an HTMLEditor component is via the getToolbar() (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.form.field.HtmlEditor-method-getToolbar) method. A shortcoming of this approach is that the HTMLEditor must be rendered before the Toolbar is available, so this method is only good for one-offs:



var toolbar = renderedEditorInstance.getToolbar();
toolbar.add({
text: 'Test',
handler: function() {
<...>
}
});


Otherwise you'll next to extend the Ext.form.field.HtmlEditor class. In particular, take a look at the source (http://docs.sencha.com/ext-js/4-1/source/HtmlEditor2.html#Ext-form-field-HtmlEditor) for this class, paying attention to the createToolbar() function.

As for adding a file-attachment button, that opens a whole different can o' worms...

hieu79vn
22 Aug 2012, 11:37 PM
Thank you my friend :)