displaying labels in marathi language - extjs

i am tring to display lable of form in marathi language for that
am creating marathi.js
this my mararhi.js
if(Ext.app.formPanel)
{
Ext.apply(Ext.app.formPanel.prototype,
{
selectUser:'नाव'
}
);
}
and my other js file contain this
var Ext.app.formPanel = Ext.extend(Ext.form.FormPanel,{
selectUser:'Select User',
initComponent : function(config) {
Ext.apply(this, {
title : 'User Rights',
bodyStyle : 'padding: 10px; background-color: #DFE8F6',
labelWidth : 100,
width : 755,
id : 'formUserRights',
renderTo:'adminpanel',
items : [ id: 'User',
fieldLabel:this.selectUser,
width:200
] //items
});//Ext.apply
Ext.app.formPanel.superclass.initComponent.apply(this, arguments);
}//init component
}); //yuyu
......
....
but it can not work
it gives error ; missing before
var Ext.app.formPanel = Ext.extend.....
but when i checked all carefully every thing is correctly nested.

First thing, the syntax error that vava noted in his comment above.
Second, you should not var the 'Ext.app.formPanel' namespace.
Third, initComponent does not pass any arguments.
Fourth, you need to call the superclass, not apply it - also no need to pass arguments, as there are none.
Ext.ns('Ext.app');
Ext.app.formPanel = Ext.extend(Ext.form.FormPanel, {
selectUser : 'Select User',
initComponent : function() {
Ext.apply(this, {
title : 'User Rights',
bodyStyle : 'padding: 10px; background-color: #DFE8F6',
labelWidth : 100,
width : 755,
id : 'formUserRights',
renderTo : 'adminpanel',
items : [ {
id : 'User',
fieldLabel : this.selectUser,
width : 200
} ]
});
Ext.app.formPanel.superclass.initComponent.call(this);
}
});
On a side note, I prefer not to use the Ext namespace for my app code, there is a chance for collision that way. I would suggest creating your own namespace.
Enjoy this one on the house, with the hope that someday you will actually award answers.

Related

The right event to apply "scrollTo" to show a dynamically added nested panel

I have a panel in ExtJS6 modern (mobile) application that can scroll vertically only. Sub panels are added dynamically to it. I need to scroll the panel to its end after adding a new sub-panel in order to make it visible. This is done using this line:
Ext.getCmp('tabmainMessagesPanel').getScrollable().scrollTo(Infinity, Infinity, true);
I execute this line in a button click, and it works (but need to click the button manually). I tried to find the right event where I can add this line to do the scroll automatically, without success. I nearly tried all the possible relevant events of the sub-panel: show, add, added, activate, ... I also tried the events of the parent panel without success.
Apparently, these events happen before the scroller of the parent panel takes into account the added sub-panel, so it scrolls to the before-last one. I smell asynchronous behavior here. The proof is that I call the scrollTo method in a delayed task of 0.5 second and it works. But this solution is not reliable.
The question is: where (in which event of which component) this line of code should go in order to scroll the parent to its end correctly?
[EDIT]
Here is the part of the code concerning the question. First, the Message class:
Ext.define('MyApp.view.message.Message', {
extend : 'Ext.Panel',
xtype : 'message',
layout : 'hbox',
config : {
mBody : ''
},
listeners: {
added: function (element) {
MyApp.view.main.Global.scroller.delay(500); //start a delayed task to scroll parent panel
}
},
items: [
{
flex : 1
},
{
maxWidth: '80%',
width: 'auto',
html : '<div class="myClass">' + this.getMBody() + '</div>'
}
]
});
Here is the delayed task that scrolls the parent panel tabmainMessagesPanel to its end in order to show the newly-added message:
Ext.define('MyApp.view.main.Global', {
statics: {
scroller: Ext.create('Ext.util.DelayedTask', function() {
Ext.getCmp('tabmainMessagesPanel').getScrollable().scrollTo(Infinity, Infinity, true);
})
}
}
Now, the tab panel that contains the panel tabmainMessagesPanel that will contain the messages:
Ext.define('MyApp.view.main.TabMain', {
extend : 'Ext.tab.Panel',
mixins : [ 'Ext.mixin.Responsive' ],
xtype : 'tabmain',
responsiveConfig : {
portrait : {
items :
[
{
title : 'Messages',
layout : 'vbox',
items : [ {
xtype: 'panel',
layout : 'vbox',
height: '100%',
id: 'tabmainMessagesPanel',
scrollable : 'vertical',
style : 'background-color:#F0F0F0'
},
{
xtype : 'inputfield',
docked : 'bottom'
}]
},
{
title : 'Connect',
layout: 'vbox',
items : [
//some UI elements
]
}
]
},
//--------------------------------------------------
landscape : {
// same as portrait
}
},
//--------------------------------------------------
controller : 'tabmain',
viewModel : 'tabmain',
defaults : {
tab : {
iconAlign : 'top'
},
styleHtmlContent : true
}
});
Finally, this is an event in a controller that creates and adds a message to tabmainMessagesPanel whenever a new message arrives:
handle_message: function (mess) {
var p = Ext.create('MyApp.view.message.Message', {
mBody : mess.body
});
Ext.getCmp('tabmainMessagesPanel').add(p);
}
Here is the answer for this. I found it 6 months later. I post it here for the benefit of those who may have the same issue.
The solution is to define the event refresh of the scroller of the panel tabmainMessagesPanel, and scroll to the end in it. So, the definition of the panel tabmainMessagesPanel becomes:
{
xtype: 'panel',
layout : 'vbox',
height: '100%',
id: 'tabmainMessagesPanel',
scrollable : 'vertical',
listeners: {
initialize: function (me) {
me.getScrollable().on('refresh', function () {
me.getScrollable().scrollTo(Infinity, Infinity, true);
});
}
},
style : 'background-color:#F0F0F0'
}

custom component reuse with extjs4

I have created a custom grid in a javascript file. I want to use it as a xtype on to different panels in seperate js files. If I use it on a single panel, it works fine; but when I use try it use it on different panels at the same time, I get a error in the chrome developer tool console saying:
Uncaught TypeError: Cannot read property 'isComponent' of undefined
My grid definition is as follows:
Ext.define('DataBox.view.FootNotes', {
extend : 'Ext.grid.Panel',
alias : 'widget.footNotes',
initComponent : function() {
this.columns = [ {
header : 'SL',
field : {
xtype : 'checkbox',
checked : 'true'
}
}, {
header : 'Symbol',
}, {
header : 'Notes',
}, ];
this.callParent(arguments);
}
});
and to include the grid on the panels i use following code
initComponent : function() {
/* this.footNotesInfoGrid = Ext.create('DataBox.view.FootNotes', {
colspan: 2,
border: false,
frame: 'false'
}); even tried this */
Ext.apply(this,{
items : [{
xtype : 'footNotes',
columnWidth : .50,
id : 'infoFootNotesGrid',
}]
}
}
I tried many other ways suggested on different forum discussions.. but my problem stil persists.
Can somebody point out where I am going wrong?
Don't assign created objects within a configuration! Use initComponent for that!
this line
plugins : [ Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit : 1
}) ],
should be placed as
this.plugins = [ Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit : 1
}) ];
anywhere in the initComponent body, but before callParent is called
Edit:
to still allow override do
if(!this.plugins) {
this.plugins = [ Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit : 1
}) ];
}
Edit
Avoid using static id properties! The framework handle that part for you. Wrap your head around Ext.ComponentQuery instead. It will help you to find any Component you are looking for.

Refs - one 'ref' few objects

I'm just wondering... is I'll define one 'ref' in a controller and will have few objects matching criteria for this 'ref', will I be able to retrieve both with the 'getter' method?
as an example the code below (Controller):
Ext.define('aBMin.controller.EmailRead', {
extend : 'Ext.app.Controller',
config : {
control : {
emailViewSubmit : {
tap : 'funEmailViewSubmit'
},
emailViewSubmitCreateTicket : {
tap : 'funEmailViewSubmitCreateTicket'
}
},
refs : {
emailViewPanel : 'emailread-panel'
,ticketViewPanel : {
selector : 'ticketview-panel',
xtype : 'ticketview-panel',
autoCreate : true
}
,dashboardPanel : 'dashboard-panel'
,emailViewSubmit : 'button[action="emailViewSubmit"]'
,emailViewSubmitCreateTicket : 'button[action="emailViewSubmitCreateTicket"]'
,ticktViewStaff : 'selectfield[alias=ticketview-supportstaffid]'
,ticketViewSubmit : 'button[action="ticketViewSubmit"]'
,emailBody : 'displayfield[name="emailbody"]'
}
View (take a note - 2 buttons with the same action = emailViewSubmitCreateTicket):
items : [{
xtype : 'button',
text : 'Create Ticket',
action : 'emailViewSubmitCreateTicket',
ui : 'confirm',
width : '100%',
hidden : true,
margin : '0 0 2px'
}, {
xtype : 'button',
text : 'Save',
action : 'emailViewSubmit',
ui : 'confirm',
width : '100%',
margin : '0 0 2px'
}, {
xtype : 'button',
text : 'Create Ticket',
action : 'emailViewSubmitCreateTicket',
ui : 'confirm',
width : '100%',
hidden : true,
margin : '0 0 2px'
}
and by the 'getter' function I mean for ex.
glob.getEmailViewSubmitCreateTicket().setHidden(false);
will this affect both of them or just one? As I've tested - this will affect only one. Any ideas how to do the same but, what I want is to affect 2 buttons at once.
refs can only return one instance which is the first that is found. If you need to get all instances use the Ext.ComponentQuery which is internally used anyway.
Sort of this should do it
Ext.Array.each(
Ext.ComponentQuery.query('button[action=emailViewSubmitCreateTicket]'),
function(item){
item.setHidden(false);
});

extjs//How can I Re-rendering Absolute Panel?

I make Panel(layout:Absolute).
After, I add Items to Panel.
But I can't see that Item.
This is need Re-Render, but I don't know how to Re-Render...
Sorry to my English, but, I'm novice at English..
Thanks!
This is Absolute and Item Code
var centerItem = {
xtype : 'image',
src : "lib/Image/Paddle.png",
x : 100,
y : 100
};
var arrayItem = new Array();
var centerRegion = Ext.create('Ext.form.Panel', {
title : 'Center Region',
region : 'center',
xtype : 'panel',
layout : 'absolute',
margins : '5 5 0 5',
id : 'designSpace',
items : this.arrayItem
});
Ext.onReady(function Startup() {
arrayItem.push(centerItem);
var Main = Ext.create('Ext.panel.Panel', {
width : '100%',
height : 960,
layout : 'border',
items : [{......
Why do you push it afterwards and not include into definition?
But really, level of all your questions suggests that you need to read ExtJs Getting Started Guide - http://docs.sencha.com/ext-js/4-0/#!/guide/getting_started
Try to create samples they do there and believe me you will fell yourself much more comfortable.

Problem with registering xtype

I am trying to create factory functions as per factory-functions-in-ext-extensions,
below is my code
Ext.ns('MyApp');
MyApp.SubmitButton = Ext.extend(Ext.Button, {
text:'Submit'
,iconCls:'icon-disk'
,initComponent:function() {
MyApp.SubmitButton.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
}); // eo extend
var btn = new MyApp.SubmitButton();
Ext.reg('submitbutton1',btn);//this is not working
Ext.reg('submitbutton', MyApp.SubmitButton );//this works
var win1;
if(!win1) {
win1 = new Ext.Window({
title : 'title',
closeAction : 'hide',
autoHeight : true,
autoWidth : true,
height : 300,
width : 500,
items : [{xtype:'submitbutton1',id:'submitbutton'}]
});
}
win1.show();
when i run this it throws error "b[d.xtype || e] is not a constructor"
You cannot use an instance of a class for registering xtype. You have to use the classname for it. Ext doesn't keep track of the instances you are creating, but just register the custom component class - so that you can just use this way:
var button = new MyApp.SubmitButton({
id : 'submitbutton'
});
OR,
{
xtype : 'submitbutton',
id:'submitbutton'
}
Both are same. Check Saki's this article for more information.

Resources