Sencha Touch Vbox - extjs

I have below requirement of a page with sencha touch:
A drop down of some options
A question posted by users (length may vary big time)
a text area to display get the answer
Two buttons for submit and ignore
I am using vbox layout. Now the problem is I want the page to be fully scrollable instead of partial scrolls on dataview etc.
How can I achieve it. I have similar requirements for different screens.
Below is the code:
Ext.define('HCMDoctor.view.PFQuestion', {
extend : 'Ext.form.Panel',
xtype : 'PFQuestion',
id : 'pfView',
config : {
layout : {
type : 'vbox',
align : 'stretch'
},
flex : 1,
scrollable : true,
items : [{
xtype : 'container',
html : 'Public Forum Question'
}, {
xtype : 'selectfield',
store : 'CommunityWiseQuestions',
name : 'pfCommId',
id : 'pfCommId',
valueField : 'communityId',
displayField : 'displayFull'
}, {
store : 'PFQuestion',
xtype : 'dataview',
flex : 1,
id : 'pfQuestionHolder',
itemTpl : ['{discussionTitle}<br>{description}',
'<br>Posted in {postedInCommunityName}']
}, {
xtype : 'hiddenfield',
id : 'pfQuestionId',
name : 'pfQuestionId'
}, {
xtype : 'textareafield',
id : 'pfAnswer',
name : 'pfAnswer'
}, {
store : 'PFQuestion',
xtype : 'button',
text : 'Ignore',
id : 'ignorePFQuestion'
}, {
store : 'PFQuestion',
xtype : 'button',
text : 'Submit',
id : 'submitPFQuestion'
}
]
}
});
Thanks

onload of store iterate over records and in every iteration create panel with tpl by passing record data to it and add the panel to its parent. something like this:
var parentPanel = Ext.getCmp("pfView");
for(var i=0; i++; i<records.size){
var mypanel = Ext.create("Ext.Panel", {
data : records[i]
});
parentPanel.add(myPanel);
}

Related

Extjs - override collapse function

i'm new of Extjs; i have a panel with the item "collapsible: true" and it works fine but...
when my specific condition is true, i want to collapse the panel, and i want to disable the button used to expand it (therefore the panel doe not show anymore, even if the click is made).
It's possible do it?
I want a type of override method that doing other things, for example to show a div with few specific information in the page.
I use only javascript and Extjs.
thanks in advance and happy holidays
I added a bindable version
Fiddle
Using databinding to collapsible, you might also add the binding to the collapsed param
Please see my snippet. Can it resolve your issue ? Tell me if you have any question.
https://fiddle.sencha.com/fiddle/1fk9
Ext.application({
name : 'Fiddle',
launch : function() {
var parent = Ext.create('Ext.container.Container', {
title : 'Demo',
renderTo : Ext.getBody(),
layout : 'vbox',
items : [{
xtype : 'checkbox',
fieldLabel : 'Enable collapsible',
handler : function(self, v){
var panel = parent.down('panel');
panel.collapseTool.setVisible(v);
panel.getHeader().down('tool[type=up]').setVisible(!v);
},
checked : true
}, {
xtype : 'panel',
width : 500,
height : 400,
title : 'Collapsible demo',
collapsible : true,
tools : [{
type : 'up',
hidden : true
}]
}]
});
}
});

ExtJS 5 bind toggle button to multiple components state

I'm working with ExtJS 5 and I need to bind the pressed config of a toggle button to the same config of an arbitrary array of another toggle buttons. In other words it should be something like this:
Ext.define('MyApp.view.MyPanel', { extend : 'Ext.panel.Panel',
alias : 'widget.myPanel',
requires : ['path to viewmodel'],
viewModel : {
type : 'myPanel'
},
items : [
{
xtype : 'button',
reference : 'btn1',
enableToggle : true
},
{
xtype : 'button',
reference : 'btn2',
enableToggle : true
},
// ... bunch of other buttons
{
xtype : 'button',
enableToggle : true,
bind : {
pressed : '{btn1.pressed && btn2.pressed}'
}
}
],
});
Furthermore I should be able to dinamically add or remove components to the dependend toggle button. How can I achieve this?

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);
});

How to make sencha components width device independent

I created register panel and added toolbar with button during view initialization, In controller i am creating form panel and adding it to the register panel dynamically.
The toolbar in register panel is adjusting based on device screen but, The form panel width is not changing.
If i set width for the form panel, The form panel is floating and width remains the same.
This is what i done so for.
Ext.define('Form.view.RegisterForm',{
extend : 'Ext.Panel',
xtype : 'register',
id : 'register',
initialize : function() {
console.log("register init");
var submit = {
xtype : 'button',
width : '100px',
ui : 'action',
text : 'Submit',
handler : this.onSubmitTap,
scope : this
};
var topToolbar = {
xtype : 'toolbar',
docked : 'top',
id : 'registerToolbar',
title : 'Form',
items : [{
xtype : 'spacer'
}, submit]
};
this.add(topToolbar);
},
config : {
fullscreen : true,
layout : {
type : 'vbox'
},
title : 'Register'
},
onSubmitTap : function() {
console.log("onSubmit");
this.fireEvent('submitCommand', this);
}
});
In Register controller i adding fields dynamically
// RegisterFormController.js
oncreateForm : function() {
var form = {
xtype: 'formpanel',
flex : 1,
id: formId,
name: formId
};
Ext.getCmp('register').add(form);
}
// calling onCreateComponent method with xtype, label, value and fromId
onCreateComponent : function(fxtype,flabel,fname,fvalue,id) {
Ext.getCmp(id).add({
xtype: fxtype,
label: flabel,
name: fname,
value: fvalue,
labelWrap:true
});
}
In case any of you came up with same problem.
The mistake i did was "I added the 4 radio buttons in a hbox panel so width of that panel increased that's why the whole form panel not displaying properly in different devices".
After i changed the panel layout as vbox, The problem solved.

paging toolbar events in ExtJS4

We are moving to ExtJS4.But we are facing an issue with paging toolbar events(onClick and onPagingKeyDown).These two are working with ExtJS3.But now these are not working.
ExtJS3 code is:
var grid = new Ext.grid.GridPanel({
store : examplestore,
columns : [{
header : s.no,
width : 40
},{
header : company name,
width : 100
},{
header : address,
width : 150
}],
bbar: new Ext.PagingToolbar({
pageSize : 10,
store : examplestore,
width : 350,
onClick : function(){
alert('you have clicked');
},
onPagingKeyDown : function(){
alert('hello');
}
})
});
ExtJS4 code is:
var grid = Ext.create('Ext.grid.GridPanel',{
store : examplestore,
columns : [{
header : s.no,
width : 40
},{
header : company name,
width : 100
},{
header : address,
width : 150
}],
bbar: Ext.create('Ext.toolbar.Paging',{
pageSize : 10,
store : examplestore,
width : 350,
onClick : function(){
alert('you have clicked');
},
onPagingKeyDown : function(){
alert('hello');
}
})
});
Now we are facing an issue with these onClick and onPagingKeyDown events that are not in ExtJS4.How to achieve these two events?
Help would be appreciated.
onPagingKeyDown is in ExtJS4. But it is private and it's not recommended to use it. Instead of both onClick and onPagingKeyDown you can use beforechange event.

Resources