extjs 4.1 how can i reset fieldcontainer in a form panel - extjs4.1

I have many fieldcontainer in a form panel. i want to reset only one fieldcontainer rather then whole panel. but i can't do this. how can i do it? here is my code
Ext.define(Fsl.app.getAbsView('V01T007001X04'), {
extend : 'Ext.form.Panel',
alias : Fsl.app.getAlias('V01T007001X04'),
id : 'V01T007001X04'.toLowerCase(),
margin : '0 0 0 0',
initComponent : function(){
this.items =[{
xtype : 'fieldcontainer',
layout : 'vbox',
items :[{
items : [{
xtype : 'fieldcontainer',
layout : 'vbox',
margin : '5 5 0 5',
items : [
{
xtype : 'numberfield',
fieldLabel : 'InvoiceNo',
name : 'invoiceId',
}]
},
{
xtype : 'fieldcontainer',
layout : 'vbox',
margin : '5 0 0 10',
items: [{
xtype : 'datefield',
name : 'date',
fieldLabel : 'Date'
}]
},{
xtype : 'fieldcontainer',
layout : 'vbox',
margin : '5 0 0 10',
items: [{
xtype : 'textfield',
name : 'branchId',
fieldLabel : 'Branch Id',
}]
}]
}]
},{
xtype : 'fieldcontainer',
combineErrors : true,
layout : 'hbox',
items: [{
xtype : 'numberfield',
fieldLabel : 'Article Id',
name : 'articleId',
}]
}];
this.callParent(arguments);
}
});

You should be able to query for the fieldcontainer you want, then run the reset() function on each of the fields inside the container. Start by giving your fieldcontainer an itemId property, so that it can be queried:
{
xtype: 'fieldcontainer',
itemId: 'invoiceCt',
items : [
{
xtype: 'numberfield',
fieldLabel: 'InvoiceNo',
name: 'invoiceId',
}]
},
Then query for the fieldcontainer and reset each field inside:
var fieldContainer = form.down('#invoiceCt');
fieldContainer.items.each(function(f) {
if (Ext.isFunction(f.reset)) {
f.reset();
}
});

Related

Sencha fieldsets are not displayed in windows phone/internet explorer

I have implemented the following using sencha 2.3.1:
I have created a sencha app with the command: sencha generate app TempApp c:/TempApp
I have replaced the default app/view/Main.js by
Ext.define('TempApp.view.Main', {
extend: 'Ext.form.FormPanel',
alias : 'widget.login',
config: {
id : 'login',
cls : ['account-login','mobile'],
layout:{
type : 'vbox',
align: 'center',
pack : 'center'
},
defaults:{
width: 240
},
scrollable: {
direction: 'vertical'
},
items:[
// TOP TOOLBAR
{
xtype : 'toolbar',
ui : 'dark',
docked : 'top',
title : '',
width : undefined
},
// FIELSDSET
{
xtype: 'fieldset',
title: 'login',
items:[
{
xtype: 'emailfield',
name : 'email',
placeHolder: 'email',
value: ''
},
{
xtype: 'passwordfield',
id : 'loginPasswordField',
name : 'password',
placeHolder: 'password',
value: ''
},
{
xtype : 'checkboxfield',
name : 'remember',
//hidden : true,
label : 'remember',
value : 'true',
checked: true,
labelWidth: '80%'
}
]
},
// AND BUTTONS
{
xtype : 'button',
id : 'loginButton',
ui : 'confirm',
text : 'login',
margin: '5',
handler: function(button, evt){
}
},
{
xtype: 'button',
id : 'forgotButton',
text : 'forgot password',
margin: '5',
handler: function(button, evt){
}
},
// BOTTOM TOOLBAR
{
xtype : 'toolbar',
ui : 'dark',
docked : 'bottom',
width : undefined
}
],
listeners: {
initialize: function(view, options){
}
}
}
});
fieldset is not displayed in internet explorer and windows phone
I have read this: http://www.sencha.com/forum/showthread.php?272642 and it seems that there is a problem with fieldsets.
How can I use fieldsets with email and password fields inside in windows phone?
First a useful tool to fix this error is the emulation tool internet explorer 11
F12 > Emulation > Explorer Profile > Windows Phone
This tool can also be useful: Remote HTML5 debugging on Windows Phone with weinre
Finally in the stylesheet of our application located in path touch/resources/css comment the following attribute in wp.css file
~ div:not(.x-msgbox) .x-input-el {/ * visibility: collapse * /}
In the controller we can use the following code for windows phone (the picker div must have a onclick event for the browser wp disregard the input onclick of which are under the mask):
Ext.define('AppName.controller.ControllerName', {
extend: 'Ext.app.Controller',
requires: [
// ...
],
config: {
refs: {
//...
},
control: {
"picker[id='PickerId']":{show:'onPickerShow'}
//...
}
},
onPickerShow: function(picker,o){
if(picker.getId()=='PickerId'){
document.getElementById("PickerId").onclick = Ext.emptyFn;
}
},

put a list inside a panel/container

I want to put a simple list into a panel or a container but doesn't work, I can see the titleBar but not the list.. this is the code:
(this Container is inside a TabPanel)
Ext.define("PrimaProva.view.ClientList", {
extend: "Ext.Container",
xtype: 'clientlist',
//fullscreen: true,
config: {
title : 'Gsrid',
iconCls: 'user',
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Clients List'
},
{
xtype: 'list',
store: 'Grid',
itemTpl: '{text}',
}
]
},
});
As you can see it is very easy…
the store "Grid" is absolutely not a problem because it works in another view….
Anyways this is the code:
Ext.define('PrimaProva.store.Grid', {
extend : 'Ext.data.Store',
requires : [
'PrimaProva.model.Grid'
],
config : {
model : 'PrimaProva.model.Grid',
data : [
{ text : 'One', amount : 1 },
{ text : 'Two', amount : 2 },
{ text : 'Three', amount : 3 },
{ text : 'Four', amount : 4 },
{ text : 'Five', amount : 5 },
{ text : 'Six', amount : 6 },
{ text : 'Seven', amount : 7 },
{ text : 'Eight', amount : 8 },
{ text : 'Nine', amount : 9 },
{ text : 'Ten', amount : 10 }
],
groupField: 'text',
}
});
Add
layout: 'fit',
fullscreen: true,
to the config of your ClientList
Working Fiddle: http://www.senchafiddle.com/#onlHz

Change form panel title sencha touch

I need to change my title inside a formpanel
Here is my code
view.js
Ext.define('bluebutton.view.BlueButton.Loyalty', {
extend: 'Ext.Container',
xtype: 'loyaltycard',
requires: [
'bluebutton.view.BlueButton.TransactionList',
'bluebutton.view.BlueButton.MemberPopUp',
'bluebutton.view.BlueButton.MemberDetail',
'bluebutton.view.BlueButton.CouponMain',
'bluebutton.store.BlueButton.MemberList',
'bluebutton.store.BlueButton.CouponList',
'Ext.ux.keypad.Keypad',
'Ext.Img',
'Ext.carousel.Carousel'
],
config: {
// iconCls: 'add_black',
// title :'Loyalty Point',
styleHtmlContent: true,
cls: 'styledContent',
//
layout: 'hbox',
border: 3,
ui: 'round',
defaults: {
margin : '10 10 10 10',
padding : 10
},
items :[
{
flex: 1,
xtype :'formpanel',
id:'loyaltyform',
items :[
{
xtype: 'fieldset',
cls :'containerRadious' ,
title: 'Welcome, new member ~<i><u>Kenny</u></i>',
defaults: {
labelWidth: '35%',
style: 'font-size:1.0em'
},
items: [
{
xtype: 'image',
src: 'resources/images/user3.png',
height: 100,
margin:20
},
{
xtype: 'textfield',
name : 'Name',
label: 'Name',
value :'Kenny Chow',
readOnly: true
},
{
xtype: 'textfield',
name : 'Age',
label: 'Age',
value :'20',
readOnly: true
},
{
xtype: 'textfield',
name : 'Point',
label: 'Point Available',
value :'50',
id :'point',
readOnly: true
},
{
xtype: 'textfield',
name : 'lastVisited',
label: 'Last Visited',
id :'lastVisited',
value :'27/12/2012 11:53 AM',
readOnly: true
},
{
xtype:'button',
text: 'Scan',
width : '100%',
id: 'btnScan',
},
]
}
]
},
{
flex: 2,
xtype :'carousel',
cls :'containerRadious' ,
items :[
{
xtype :'keypad',
layout: {
type: 'hbox',
pack: 'center'
},
},
{
xtype:'couponlistcard'
}
]
}
],
}
});
Controller
onbtnAddClick: function (e) {
var loyaltyform = Ext.getCmp('loyaltyform');
var pointAvalaible = Ext.getCmp('point').getValue();
var keyPadValue = Ext.getCmp('keypad_value').getValue();
var consumerID = Ext.getCmp('keypad_value').getValue();
Ext.getCmp('loyaltyform').setTitle('Changed Title');;
}
but i get this error.
**Uncaught TypeError: Object [object Object] has no method 'setTitle'**
Anyone face this problem before? please help
The reason you get the error is because a formpanel has no method setTitle(). To change the title you have to call the setTitle() method of your fieldset, which is inside your formpanel. So give you fieldset an ID and use this:
Ext.getCmp('yourFieldsetID').setTitle('Changed Title');
Check the methods you can use for a panel en fieldset in the Sencha docs:
http://docs.sencha.com/touch/2-1/#!/api/Ext.form.Panel
http://docs.sencha.com/touch/2-1/#!/api/Ext.form.FieldSet
Good luck!

Adding a form to the timeline object in sencha touch

I have taken the form example from Sencha Touch API
var form = new Ext.form.FormPanel({
items: [
{
xtype: 'textfield',
name : 'first',
label: 'First name'
},
{
xtype: 'textfield',
name : 'last',
label: 'Last name'
},
{
xtype: 'numberfield',
name : 'age',
label: 'Age'
},
{
xtype: 'urlfield',
name : 'url',
label: 'Website'
}
]
});
and I have created a timeline object using
timeline = new Ext.Component({
title: 'Loan Details',
cls: 'timeline',
scroll: 'vertical',
tpl: ['<div></div>']
});
and then added the timeline to the panel as:
panel = new Ext.TabPanel({
fullscreen: true,
cardSwitchAnimation: 'slide',
ui: 'light',
items: [timeline]
});
How can I add the form object to the timeline? Like how I can show that on it? Where I should add it?
Thanks for the response in advance.
I'm not sure what you are trying to do. Are you trying to have some kind of continuous carousel where you will put the FormPanel?
If so you should extend the Ext.Panel to make that timeline object and then as item use the xtype:'fieldset' and have the form items there.
For example:
App.views.Timeline = Ext.extend(Ext.Panel, {
initComponent: function() {
Ext.apply(this, {
title: 'Loan Details',
cls: 'timeline',
scroll: 'vertical',
items:[
{
xtype: 'fieldset',
defaults: {
labelAlign: 'left',
labelWidth: 'auto',
}
items: [
{
xtype: 'textfield',
name : 'first',
label: 'First name'
},
{
xtype: 'textfield',
name : 'last',
label: 'Last name'
},
{
xtype: 'numberfield',
name : 'age',
label: 'Age'
},
{
xtype: 'urlfield',
name : 'url',
label: 'Website'
}
]
}
]
});
}});
the Ext.Component is for showing data through the data property. The data is display according to the template you provide i.e. the tpl property but you need to specify the property of the objects you want to show. For example tpl:<div>{text}</div> and data:[{text:'Example'}]

Sencha touch list with json store

I have a problem with a store that carries the data in a List, the thing is that the store is doing the load but the List stays in Loading, what I'm doing wrong, thanks
Ext.regModel('Properties', {
fields: [
{name: 'idcounty', type: 'string'},
{name: 'county', type: 'string'}
]
});
store = new Ext.data.Store({
model : 'Properties',
proxy: {
type: 'ajax',
url: 'php/response_grid.php?module=countys',
reader: {
type: 'json',
root: 'results',
totalCount: 'total'
}
},
autoLoad:true
});
var listPanel = {
dockedItems: [
{
title: 'Results',
xtype: 'toolbar',
ui: 'light',
dock: 'top'
}
],
layout: 'fit',
scroll: 'vertical',
items: [
{
xtype: 'list',
itemTpl : '{county}',
store: store,
singleSelect: true,
onItemDisclosure: function(record, btn, index){
}
}
],
flex:1
};
and the json answer from the php
({"total":"67","results":[{"idcounty":"1","county":"Broward"},{"idcounty":"2","county":"Dade"},{"idcounty":"3","county":"Palm Beach"},{"idcounty":"4","county":"Osceola"},{"idcounty":"5","county":"Lake"},{"idcounty":"6","county":"Orange"},{"idcounty":"7","county":"Seminole"},{"idcounty":"8","county":"Volusia"},{"idcounty":"9","county":"Hillsborough"},{"idcounty":"10","county":"Polk"},{"idcounty":"11","county":"Pasco"},{"idcounty":"12","county":"Pinellas"},{"idcounty":"13","county":"Sarasota"},{"idcounty":"14","county":"Manatee"},{"idcounty":"15","county":"Charlotte"},{"idcounty":"16","county":"Alachua"},{"idcounty":"17","county":"Baker"},{"idcounty":"18","county":"Bay"},{"idcounty":"19","county":"Bradford"},{"idcounty":"20","county":"Brevard"},{"idcounty":"21","county":"Calhoun"},{"idcounty":"22","county":"Citrus"},{"idcounty":"23","county":"Clay"},{"idcounty":"24","county":"Collier"},{"idcounty":"25","county":"Columbia"},{"idcounty":"34","county":"Duval"},{"idcounty":"35","county":"Escambia"},{"idcounty":"36","county":"Flagler"},{"idcounty":"37","county":"Franklin"},{"idcounty":"38","county":"Gadsden"},{"idcounty":"39","county":"Gilchrist"},{"idcounty":"40","county":"Glades"},{"idcounty":"41","county":"Gulf"},{"idcounty":"42","county":"Hamilton"},{"idcounty":"43","county":"Hardee"},{"idcounty":"44","county":"Hendry"},{"idcounty":"45","county":"Hernando"},{"idcounty":"46","county":"Highlands"},{"idcounty":"47","county":"Holmes"},{"idcounty":"48","county":"Jackson"},{"idcounty":"49","county":"Jefferson"},{"idcounty":"50","county":"Lafayette"},{"idcounty":"52","county":"Lee"},{"idcounty":"53","county":"Leon"},{"idcounty":"54","county":"Levy"},{"idcounty":"55","county":"Liberty"},{"idcounty":"56","county":"Madison"},{"idcounty":"58","county":"Martin"},{"idcounty":"59","county":"Monroe"},{"idcounty":"60","county":"Nassau"},{"idcounty":"61","county":"Okaloosa"},{"idcounty":"62","county":"Okeechobee"},{"idcounty":"63","county":"Putnam"},{"idcounty":"64","county":"Sumter"},{"idcounty":"65","county":"Taylor"},{"idcounty":"66","county":"Union"},{"idcounty":"67","county":"Wakulla"},{"idcounty":"68","county":"Walton"},{"idcounty":"69","county":"Washington"},{"idcounty":"70","county":"DeSoto"},{"idcounty":"71","county":"IndianRiver"},{"idcounty":"72","county":"SantaRosa"},{"idcounty":"75","county":"St Johns"},{"idcounty":"77","county":"St Lucie"},{"idcounty":"78","county":"Dixie"},{"idcounty":"80","county":"Suwannee"},{"idcounty":"81","county":"Marion"}]})
I got your example to work but I had to change a few things, I wrapped it in an application just to get to work. Specifically I had to move the model AFTER the Application so that the Store was available.
In the above example you just do:
store = new Ext.data.Store({...
I think you need to do:
var stor = new Ext.data.Store({...
Anyway here is the code I got to work, so your data is good...
Ext.ns("Test", "Test.stores");
Test = new Ext.Application({
defaultTarget : 'viewport',
name : 'test',
icon : 'icon.png',
glossOnIcon : false,
tabletStartupScreen : 'tablet_startup.png',
phoneStartupScreen : 'phone_startup.png',
launch : function() {
console.log('begin');
this.viewport = new Ext.Panel({
fullscreen : true,
dockedItems : [ {
title : 'Results',
xtype : 'toolbar',
ui : 'light',
dock : 'top'
} ],
layout : 'fit',
scroll : 'vertical',
items : [ {
xtype : 'list',
itemTpl : '<span id="{idcounty}">{county}</span>',
store : Test.stores.Properties,
singleSelect : true,
itemSelector : 'span.id',
onItemDisclosure : function(record, btn, index) {
}
} ],
flex : 1
});
}
});
Ext.regModel('Properties', {
fields : [ {
name : 'idcounty',
type : 'string'
}, {
name : 'county',
type : 'string'
} ]
});
Test.stores.Properties = new Ext.data.Store({
model : 'Properties',
proxy : {
type : 'ajax',
url : 'test.json',
reader : {
type : 'json',
root : 'results',
totalCount : 'total'
}
},
autoLoad : true
});