Am having a controller which basically calls a message window that is displayed for a few seconds. Am trying to add a button to this message window, but its returning [object][object].
Controller
success : function(response) {
this.mWin = Ext.create('App.view.GenMessage');
this.mWin.addMessage(true, LANG.SUCT, LANG.SUCTxt1);
}
View
Ext.define('App.view.GenMessage', {
extend : 'Ext.panel.Panel',
alias : 'widget.genmessage',
initComponent : function() {
this.msgCt = App.genMsgCt
this.msgCt.setWidth(300);
},
addMessage : function(status, title, msg) {
if (status == false) {
delay = 3000;
} else {
delay = 2000;
}
Ext.DomHelper.append(this.msgCt, {
html : this.buildMessageBox(status, title, msg)
}, true).slideIn('t').pause(delay).ghost("t", {
remove : false
});
},
/*
* buildMessageBox
*/
buildMessageBox : function(status, title, msg) {
console.log('buildMesssage');
switch (status) {
case true :
var icon = GENHTML.tick;
break;
case false :
var icon = GENHTML.warning;
break;
}
return ['<div class="genMsgDiv">', icon,
'<div class="genMsgHd leftMargin">', title,
'</div><div class="H3 leftMargin">', msg,
'</div></div>'].join('');
}
What i did was declare a button like
var button={
id: 'button1',
text :'Button1'
}
and then add to the div class mentioned above and return
['<div class="genMsgDiv">', button].join();
But, what i see in the screen is [object][object] in place of the button.
Could anyone please tell me what am doing wrong here. Is this the correct way to add the button
EDIT
Since we cannot add a button to a div, i tried doing
var config = Ext.create(Ext.panel.Panel, {
itemId : 'GENMSGPANEL',
height : 150,
cls : 'msg effect1',
border : false,
html : '<div class="genMsgDiv">' + icon +
'<div class="genMsgHd leftMargin">'+ title +
'</div><div class="H3 leftMargin">'+ msg +
'</div></div>',
items : [{
xtype : 'panel',
//cls : 'winTitle',
}, {
xtype : 'form',
itemId : 'GENMSGFORM',
border : false,
title : '',
buttonAlign : 'center',
fieldDefaults : {
msgTarget : 'side',
labelWidth : 110,
size : 30
},
buttons : [{
text : LANG.BTYES,
iconCls : 'icon-tick-tb',
iconAlign : 'right',
cls : 'tip-btn',
action : 'genDelete',
id : 'BTYES'
}, {
text : LANG.BTNO,
iconCls : 'icon-cross-tb',
iconAlign : 'right',
cls : 'tip-btn',
action : 'notDelete',
id : 'BTNO'
}]
}]
});
return config;
But, even this did not return anything
The answer is simple: You cannot add a ExtJS Button into the html config property of a component. This one is just for plain html. ExtJS objects belongs into the items array.
Decide to place your html content into a box (xtype for component) and add this to the items array. Then you can add your button. Don't use the html at all in your case.
You may change/set any required classes. Please note that I haven't check the way you manipulate the DOM.
// you may use a layout to align them
items : [
{
xtype: 'box',
cls : 'msg effect1',
html : '<div class="genMsgDiv">' + icon +
'<div class="genMsgHd leftMargin">'+ title +
'</div><div class="H3 leftMargin">'+ msg +
'</div></div>'
},
{
xtype : 'panel',
//cls : 'winTitle',
},
...
Related
I am trying to submit the values from the menu buttons but know this is not possible and that I have to create a hidden field and store the button values there.
Being new to ExtJs I can not seem to figure out how to do this. Below is the basic layout I used to check the button shows and I can choose a colour.
getFormItems : function() {
var me = this;
return [{
xtype : "fieldset",
title : "Items to monitor",
defaults : {
labelSeparator : ""
},
items : [{
xtype : "checkbox",
name : "cpuenable",
boxLabel : _("Will monitor CPU Temperature"),
fieldLabel : _("CPU Temperature"),
checked : false
},{
xtype : 'hiddenfield',
id : 'buttonvalues'
},{
xtype : "button",
name : "colours",
text : _("Choose Colours"),
scope : this,
style : {
marginTop : "10px",
marginBottom : "10px"
},
menu: [{
text: "Main CPU Colour",
menu: {
xtype : "colormenu",
name : "colourc",
value : "000000",
cls : "menubutton-class",
handler: function (obj, rgb) {
var colourmField = this.findField('colourc');
colourmField.setValue(rgb.toString());
alert(colourmField.getValue());
}
}
},{ and so on
Okay, here is an edit for you of my previous post. I give you an example how to fetch all child components you want inside a component:
Example extjs:
{
xtype: 'fieldset',
id: 'fsButtons',
items: [
{
xtype: 'hiddenfield',
id: 'hiddenValues'
},
{
xtype: 'button'
color: '000000'
},
{
xtype: 'button'
color: '555555'
}
]
}
Function to fill the hiddenfield:
function getButtonVars() {
var buttonVars = new Array();
//Get all components with xtype 'button' inside the fieldset with id 'fsButtons'
Ext.Array.each(Ext.ComponentQuery.query('button', Ext.getCmp('fsButtons'), function(button){
buttonVars.push(button.color);
});
Ext.getCmp('hiddenValues').setValue(buttonVars.join(',')); // concats all button values to one string: '000000,555555' etc.
}
I hope it's clear now :)
http://docs-origin.sencha.com/extjs/4.2.2/#!/api/Ext.ComponentQuery
I would like to change default contextmenu and customize the create function with submenus: create service and create application. Then I would also like to associate icons with the service and application submenus.
I searched available solutions on stackoverflow and modified it to suit my requirements. But it does not work.
So far, when I click on submenu the alert box is displayed. But the create node does not work. The icons are not displayed either.
Can someone please tell me how to fix this?
"contextmenu" : {
items : { b
"create" : {
"separator_before" : false,
"separator_after" : true,
"label" : "Create",
"action" : false,
"submenu" :{
"create_service" : {
"seperator_before" : false,
"seperator_after" : false,
"label" : "service",
"icon": "service.png",
action : function (obj) {
alert("creating service");
this.create(obj, "last", {"attr" : {"rel" : "service"}});
}
},
"create_application" : {
"seperator_before" : false,
"seperator_after" : false,
"label" : "app",
"icon": "app.png",
action : function (obj) {
alert("creating app");
this.create(obj, "last", {"attr" : { "rel" : "application"}});
}
}
}
}
}
}
check line 2, and remove the "b":
items : { b
As an example, a snippet of my contect menu (maybe this helps):
"contextmenu": {
"items": {
"create" : false,
"ccp" : false,
"rename" : false,
"remove" : {
"label" : " Delete",
"icon" : "/images/icon/cross.png"
}
}
},
Use full path for the icon image, like this
icon: "/Content/images/deleteIcon.gif"
I want to use jtable in jquery UI dialogue widget. I'm loading the content of dialogue widget dynamically as follows
$( "#dialog4" ).dialog({
autoOpen: false,
height:$(window).height() - 50,
width:$(window).width() - 50,
show: {
effect: "blind",
duration: 400,
},
hide: {
effect: "explode",
duration: 400
},
open: function (){
$(this).load("managegroupmembers.jsp");
}
});
my jtable code is present in managegroupmembers.jsp. It is as follows:
<script>
$(function() {
$('groupmembers')
.jtable(
{
title : 'Members in Group',
jqueryuiTheme : true,
selecting : true, //Enable selecting
multiselect : true, //Allow multiple selecting
selectingCheckboxes : true,
paging : true,
pageSize : 20,
pageSizes : [ 20, 50, 75, 100, 200, 500 ],
defaultSorting : 'fullName ASC',
sorting : true,
actions : {
listAction : 'group'
},
fields : {
groupID : {
key : true,
list : false
},
memberID : {
key : true,
list : false
},
fullName : {
create : false,
edit : false,
title : 'Name',
width : '15%'
},
memberRole : {
title : 'Role in Group',
width : '7%',
display : function(data) {
var roleName = "";
if (data.record.memberRole != null) {
roleName = data.record.memberRole.roleName;
}
return roleName;
}
},
memberSince : {
list : true,
title : 'Member Since',
inputClass : 'text ui-widget-content ui-corner-all inputClass'
}
}
});
$('#groupmembers').jtable('load');
});
</script>
<div id="groupmembers" class="ui-widget"></div>
I tried to debug the code using chrome's developer tools and I'm seeing following error:
"cannot call methods on jtable prior to initialization; attempted to call method 'load'"
Can anybody help me here? Thanks in advance.
You are not initializing the jTable because you forgot the # in front of the groupmembers ID in the init code....
$('groupmembers')
should be:
$('#groupmembers')
I have put a button on a dataGrid with the following code
column is;
var avaliableAction = {
header : "Action",
width : 120,
sortable : true,
align : "left",
dataIndex : 'status',
renderer : statusRenderer
};
data grid is;
var mainJobsGrid = new Ext.grid.GridPanel({
store : jobsStore,
columns : [ avaliableAction ],
viewConfig : {
forcefit : true
},
title : 'Data Mart Jobs',
height : 198,
width : 540,
frame : true
});
renderer is;
function statusRenderer(value, id, r) {
var START_ICON = '/etlscheduler/resources/images/start-icon.png';
var STOP_ICON = '/etlscheduler/resources/images/stop-icon.png';
if (value == "STOPPED") {
return "<input type='button' class='btnStart' onClick='doStart(); '>";
} else if (value == "RUNNING" || value == "WAITING") {
return "<input type='button' class='btnStop' onClick='doStop();'>";
}
};
and
function doStop() { ... }
function doStart() { ... }
The problem is that when I click the button exception occurs as "doStop is not defined"
seems like you need to define the function
function doStop() { ... }
I faced the same problem, and it wasn't a typo! i have noticed that the implementation of the called function works only if it was outside the "Ext.onReady(function(){}".
If someone faces the same problem, i have solved it through writing the function as following:
Ext.the_function = function(){...}
instead of :
var the_function = function(){...}
This would fix the problem and it will work wherever you put it!
I'm trying to create TinyMCE Menu Button which should open multiple popup window manager. It works fine but the button image doesn't appear.
here is the code. Am I doing something wrong?
(function() {
tinymce.create('tinymce.plugins.shortcodes', {
init : function(ed, url) {
ed.addCommand('scTypography', function() {
ed.windowManager.open({
file : url + '/dialog.htm',
width : 800 + ed.getLang('example.delta_width', 0),
height : 500 + ed.getLang('example.delta_height', 0),
inline : 1
});
});
ed.addCommand('scColumns', function() {
ed.windowManager.open({
file : url + '/dialog.htm',
width : 800 + ed.getLang('example.delta_width', 0),
height : 500 + ed.getLang('example.delta_height', 0),
inline : 1
});
});
ed.addCommand('scButtons', function() {
ed.windowManager.open({
file : url + '/dialog.htm',
width : 800 + ed.getLang('example.delta_width', 0),
height : 500 + ed.getLang('example.delta_height', 0),
inline : 1
});
});
},
createControl : function(n, cm) {
switch (n) {
case 'shortcodes':
var c = cm.createMenuButton('shortcodes', {
title : 'My menu button',
image : '/btn.png'
});
c.onRenderMenu.add(function(c, m) {
var sub;
sub = m.addMenu({title : 'Some item 3'});
sub.add({title : 'Typography', onclick : function() {
tinyMCE.activeEditor.execCommand('scTypography');
}});
sub.add({title : 'Layout Columns', onclick : function() {
tinyMCE.activeEditor.execCommand('scColumns');
}});
sub.add({title : 'Buttons', onclick : function() {
tinyMCE.activeEditor.execCommand('scButtons');
}});
});
// Return the new menu button instance
return c;
}
return null;
},
});
tinymce.PluginManager.add('shortcodes', tinymce.plugins.shortcodes);
})();
I'm not dev, but trying to understand this part to use in Wordpress theme.
Any one can help please?
While the URL to the toolbar image is absolute, you can use the value of the url supplied in init() function that is the URL to the plugin location. For example
image : url + '/btn.png'
Additional to Bretts answer you may need to put the button explicitly into the button config part of the tinymce init.
Example:
I added my own ßplugins buttons to the tinymce UI using this code onInit in my own plugins:
// Register my_button
ed.addButton('my_button', {
title : 'Click me!',
cmd : 'my_command',
image : url + "my_image.png";
});
and here the relevant part of the tinymce init
theme_advanced_buttons1:"style,bold,italic,underline",
theme_advanced_buttons2: "cleanup,save,preview,my_button", // <-- here