I want to display a list from sencha store. I want to display it as a table with header, hence I thought Grid would be perfect for it. But I am getting this errorUncaught TypeError: Cannot call method 'substring' of undefined Is it because I used Grid as an item in Container? If not whats the problem, how can I achieve my goal? I have commented out Grid. I used a "list" to display records but as I want to add a header to the list, I think Grid would do it more easily.'Ext.define("PocketCRM.view.InvestorsList", {
extend: "Ext.Container",
requires: [
"Ext.dataview.List",
],
alias: "widget.investorslistview",
config: {
layout: {
type: "vbox",
},
items: [
{
xtype: "toolbar",
docked: "top",
title: "Investor Details",
items: [
{
xtype: "button",
ui: "back",
text: "Back",
itemId: "backToDeal"
}
]
},
{
xtype: "label",
html: "Select a Client Area"
},
{
xtype: "list",
store: "Investors",
itemId : "InvestorsList",
onItemDisclosure: true,
indexBar: false,
grouped: false,
disableSelection: false,
loadingText: "Loading Investors...",
emptyText: '<div class="leads-list-empty-text">No Investors found.</div>',
itemCls : "dataview-item",
itemTpl:[
'<table border="0" cellpadding="2" cellspacing="2" style="width:95%; margin-top:0px;"><tr>',
'<td style="width:20%; text-align: center; line-height: 3; font-size: 16px;">{Account__c}</td>',
'<td style="width:20%; text-align: center; line-height: 3; font-size: 16px;">{Primary_Contact_Name__c}</td>',
'<td style="width:20%; text-align: center; line-height: 3; font-size: 16px;">{Status__c}</td>',
'<td style="width:15%; text-align: center; line-height: 3; font-size: 16px;">{Contact_Phone__c}</td>',
'<td style="width:20%; text-align: center; line-height: 3; font-size: 16px;">{Primary_Contact_Email__c}</td>',
'</tr></table>'
],
listeners : {
scope : this,
itemtap : function(dataview, index, el, record, e){
//Browser event e
console.log(e.target,Ext.get(e.target).getAttribute('id'));
var formPanel = Ext.create('Ext.form.Panel',{
modal : true,
hideOnMaskTap : true,
centered : true,
scrollable : 'vertical',
width : 400,
height : 200,
layout: { type: 'vbox', align: 'stretch' },
items:[{
xtype: 'selectfield',
name: 'Status__c',
label: 'Status',
options: [
{text: 'Pending', value: 'Pending'},
{text: 'Accepted', value: 'Accepted'},
{text: 'Final Bidder', value: 'Final Bidder'},
{text: 'Dropped', value: 'Dropped'},
{text: 'Rejected', value: 'Rejected'},
{text: 'Closed', value: 'Closed'}
]
},
{xtype: 'spacer'},
{xtype: 'spacer'},
{
xtype: 'button',
//width : 100,
text: 'Save',
handler: function(){
console.log('Inside Save');
var InvStore = Ext.getStore('Investors');
InvStore.sync();
console.log('Completed Sync');
formPanel.hide();
}
},
{xtype: 'spacer'},
{
xtype: 'button',
text: 'Cancel',
//width : 100,
handler: function(){
formPanel.hide();
}
}]
});
formPanel.setRecord(record);
Ext.Viewport.add(formPanel).show();
}
}
},
{
//xtype: "grid.panel",
//columns: [
// {text: 'Account', dataIndex:'Account__c'},
//],
},
],
listeners: [
{
delegate: "#backToDeal",
event: "tap",
fn: "onBackDealTap"
},
{
delegate: "#InvestorsList",
event: "disclose",
fn: "onInvestorsListDisclose"
}
]
},'
The xtype is not grid.panel, it's just grid.
Relevant doc link: http://docs.sencha.com/touch/2.3.1/#!/api/Ext.grid.Grid
Related
How to get the record of selected grid row in EXTJS modern toolkit, but when listeners uses delegated event?
I added appropriate listener in grid component, and that provides information about selected div, but this is comppletelly useless unless the onformation which record is clicked in known.
In classic tolkit there is something like 'record,data' and 'recordIndex', but I don't see anything similar on modern toolkit.
var store = Ext.create('Ext.data.Store', {
fields: [{
name: 'name1',
type: 'string'
}, {
name: 'name2',
type: 'string'
}],
data: [{
name1: 'John',
name2: 'Smith',
}],
});
Ext.create('Ext.Container', {
renderTo: Ext.getBody(),
height: 700,
items: [{
xtype: 'grid',
cls: 'grid',
//rowLines: false,
height: 700,
store: store,
columns: [{
text: '',
xtype: 'templatecolumn',
cell: {
encodeHtml: false
},
tpl: new Ext.XTemplate(
'<div class="grid-box">',
'<div class="name">{name1}</div>',
'<div class="name">{name2}</div>',
'</div>',
),
flex: 1
}],
listeners: {
click: {
element: 'element',
delegate: 'div.grid-box',
fn: function (a, b, c) {
debugger;
console.log(a, b, c);
}
}
}
}]
});
CSS
.grid .x-show-selection > .x-listitem.x-selected {
background-color: pink;
}
.grid .x-show-selection > .x-listitem.x-selected {
background-color: pink;
}
.grid .x-listitem {
background-color: #a9f1ad;
}
.grid-box {
background: #fff;
border: 1px solid #cbd2d6;
padding: 15px;
height: 100%;
}
.grid .x-gridcell-body-el {
padding: 5px 0px 5px 10px;
}
.name {
font-size:22px;
line-height:22px;
}
Store recordId in wrapper div attribute and read it in tap handler:
var store = Ext.create('Ext.data.Store', {
fields: [{
name: 'name1',
type: 'string'
}, {
name: 'name2',
type: 'string'
}],
data: [{
name1: 'John',
name2: 'Smith',
}, {
name1: 'Muster',
name2: 'Mustermann',
}],
});
Ext.create('Ext.Container', {
renderTo: Ext.getBody(),
height: 700,
items: [{
xtype: 'grid',
cls: 'grid',
//rowLines: false,
height: 700,
store: store,
columns: [{
text: '',
xtype: 'templatecolumn',
cell: {
encodeHtml: false
},
tpl: new Ext.XTemplate(
'<div class="grid-box" recordId={id}>', // Store recordId in div attribute
'<div class="name">{name1}</div>',
'<div class="name">{name2}</div>',
'</div>',
),
flex: 1
}],
listeners: {
click: {
element: 'element',
delegate: 'div.grid-box',
fn: function (a, b, c) {
var grid = Ext.getCmp(this.id),
store = grid.getStore(),
record = store.getById(b.getAttribute('recordId'))
console.log(record.getData());
}
}
}
}]
});
Here is my code i dont know why it didnt work ..the error in the console is
[W] [Ext.Loader] Synchronously loading 'widget.polar'; consider adding Ext.require('widget.polar') above Ext.onReady Util.js?_dc=1404383474396:692
GET http://localhost/widget/polar.js?_dc=1404383480019 404 (Not Found) bootstrap.js:558
Uncaught Error: [Ext.create] Unrecognized class name / alias: widget.polar ClassManager.js?_dc=1404383474396:1405
[E] [Ext.Loader] Some requested files failed to load. Util.js?_dc=1404383474396:692
Object
Util.js?_dc=1404383474396:698
console.trace() Util.js?_dc=1404383474396:704
log Util.js?_dc=1404383474396:704
Ext.apply.raise Error.js?_dc=1404383474396:186
Ext.apply.onLoadFailure Loader.js?_dc=1404383474396:649
(anonymous function) bootstrap.js:728
Uncaught Error: [Ext.Loader] Some requested files failed to load. Error.js?_dc=1404383474396:103
im just trying to create an Spie like in the example :http://dev.sencha.com/ext/5.0.0/examples/kitchensink/?charts=true#pie-custom
Ext.define('App.view.main.Main', {
extend: 'Ext.container.Container',
requires: 'App.view.main.TabPanel',
xtype: 'app-main',
controller: 'main',
viewModel: {
type: 'main'
},
layout: {
type: 'border'
},
items: [
{
region: 'center',
xtype: 'customtabpanel'
}]
});
and input it into my TAB .... i dunno why didnt work
app/view/main/TabPanel.js
Ext.define('App.view.main.TabPanel', {
extend: 'Ext.tab.Panel',
xtype: 'customtabpanel',
requires:['App.view.main.Pie'],
ui: 'navigation',
tabPosition: 'left',
tabRotation: 0,
tabBar: {
border: false
},
items: [{
title: 'Active Tab 1',
html: 'Active Link One',
xtype: 'pie-custom',
}, {
title: 'Active Tab 2',
html: 'Active Link Two'
}, {
title: 'Active Tab 3',
html: 'Active Link Three'
}, {
title: 'Active Tab 4',
html: 'Active Link Four'
}]
});
app/view/main/Pie.js
Ext.define('App.view.main.Pie', {
extend: 'Ext.Panel',
xtype: 'pie-custom',
// <example>
bodyStyle: 'background: transparent !important',
layout: {
type: 'vbox',
pack: 'center'
},
// </example>
width: 650,
initComponent: function() {
var me = this;
//<example>
me.tbar = [
'->',
{
text: 'Preview',
handler: function() {
me.down('polar').preview();
}
}
];
//</example>
me.items = [{
xtype: 'polar',
width: '100%',
height: 500,
store: {type: 'device-market-share'},
insetPadding: 30,
innerPadding: 20,
legend: {
docked: 'bottom'
},
interactions: ['rotate', 'itemhighlight'],
sprites: [{
type: 'text',
text: 'Pie Charts - Custom Slice Sizing',
font: '22px Helvetica',
width: 100,
height: 30,
x: 40, // the sprite x position
y: 20 // the sprite y position
}, {
type: 'text',
text: 'Data: IDC Predictions - 2017',
font: '10px Helvetica',
x: 12,
y: 425
}, {
type: 'text',
text: 'Source: Internet',
font: '10px Helvetica',
x: 12,
y: 435
}],
series: [{
type: 'pie',
animation: {easing: 'easeOut', duration: 500},
angleField: 'data1', // bind angle span to visits
lengthField: 'data2', // bind pie slice length to views
clockwise: false,
highlight: {
margin: 20
},
label: {
field: 'os', // bind label text to name
display: 'outside',
font: '14px Arial'
},
style: {
strokeStyle: 'white',
lineWidth: 1
},
tooltip: {
trackMouse: true,
renderer: function(storeItem, item) {
this.setHtml(storeItem.get('os') + ': ' + storeItem.get('data1') + '%');
}
}
}]
//<example>
}, {
style: 'padding-top: 10px;',
xtype: 'gridpanel',
columns : {
defaults: {
sortable: false,
menuDisabled: true
},
items: [
{ text: 'OS', dataIndex: 'os' },
{ text: 'Market Share', dataIndex: 'data1', width: 150, renderer: function(v) { return v + '%'; } },
{ text: 'Growth', dataIndex: 'data2', width: 150, renderer: function(v) { return v + '%'; } }
]
},
store: {type: 'device-market-share'},
width: '100%'
//</example>
}];
this.callParent();
}
});
can you help me out why is this error happen ???
Try to add "ext-charts" to "requires" section of your app.json in line 42
I'm writing an app in Sencha-touch. I have 3 tabs in a tab panel. I'd like each one to take up 33% of the width of the tab panel. I've tried using resizeTabs, tabWidth, and even added a class to each item and then referenced it in css to change the width.
Then I also tried using a span element in the html and referencing that. But none of it works. My code is below. How do I change the width of the tabs in a tab panel?
{
xtype: 'tabpanel',
fullscreen: true,
tabBarPosition: 'top',
resizeTabs: true,
tabWidth: '33%',
items:[
{
//title: 'Campus List',
html: '<span class="headerTab">Campus List</span>',
width: '33%',
cls: 'headerTab'
},
{
title: 'Meter List',
html: 'Meter List',
width: '33%',
cls: 'headerTab'
},
{
title: 'Meter',
html: 'Meter',
width: '33%',
cls: 'headerTab'
}
]
}
I figured it out. If you reference the xtype of the tab, not the tabpanel, in your css then it will resize the tabs. Here's what worked.
.x-tab{
width: 33%;
}
{
xtype: 'tabpanel',
tabBarPosition: 'top',
**
defaults: {
flex: 1 //set the width of each item to be equal, in this case => 100%/numberOfItems = 100%/3 = 33.33333%
}
**
items:[
{
title: 'Campus List'
},
{
title: 'Meter List'
},
{
title: 'Meter'
}
]
}
have you tried using "flex" config ?
this the solution that I use
{
xtype: 'tabpanel' ,
fullscreen: true,
tabBarPosition: 'top',
resizeTabs: true,
// use this it helps
minTabWidth : 75,
//*********
items:[
{
//title: 'Campus List',
html: '<span class="headerTab">Campus List</span>',
width: '33%',
cls: 'headerTab'
},
{
title: 'Meter List',
html: 'Meter List',
width: '33%',
cls: 'headerTab'
},
{
title: 'Meter',
html: 'Meter',
width: '33%',
cls: 'headerTab'
}
]
}
I work with extjs4
I have a grid and I want to add icon related to condition in the gride
I have a css class
but the probleme that the icon displays several times
my code css :
.contactIcon80 {
background-image: url(/UrbanPlanning/theme/images/delete.png);
width:80px!important;
height:80px!important;
margin-right: auto !important;
margin-left: auto !important;
}
my code extjs :
function showUpdated(value, metaData, record, rowIndex, colIndex, store) {
if(record.get("statut_reqUPReliance")=="WaitingAccept") {
metaData.css = ' contactIcon80';
}
return value;
}
var RequestUPRelianceListGrid1 = Ext.create('Ext.grid.Panel', {
id:'RequestUPRelianceListGrid1',
store: RequestUPRelianceListGridStore,
collapsible:true,
title:'title',
columns: [
{xtype: 'checkcolumn', header: 'test',dataIndex: 'checked', width: 60,listeners:{'checkchange': RequestUPRelianceGridSelectionChanged}},
{text: 'numero', flex: 1, sortable: true, hidden:true, dataIndex: 'num_reqUPReliance'},
{text: 'statut', flex: 1, sortable: true, dataIndex: 'statut_reqUPReliance', renderer: showUpdated}
],
columnLines: true,
anchor: '100%',
frame: true,
height: 250,
margin: '5 5 5 5',
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
ui: 'footer',
layout: {
pack: 'center'
},
items: [
{
xtype: 'button',
text: 'new',
id:'new_R',
handler: function() {
}
}
]
}]
});
now I tried with this code :
.contactIcon80{
background-image: url("/UrbanPlanning/theme/images/delete.png") !important;
background-position:center !important;
width: auto !important;
background-repeat: no-repeat;
}
it work without error
Now I want to add the notion of tooltip
I try to modify my code with :
function showUpdated(value, metaData, record, rowIndex, colIndex, store) {
if(record.get("statut_reqUPReliance")=="WaitingAccept") {
metaData.css = ' contactIcon80';
}
return value;
}
var RequestUPRelianceListGrid1 = Ext.create('Ext.grid.Panel', {
id:'RequestUPRelianceListGrid1',
store: RequestUPRelianceListGridStore,
collapsible:true,
title:'title',
columns: [
{xtype: 'checkcolumn', header: 'test',dataIndex: 'checked', width: 60,listeners:{'checkchange': RequestUPRelianceGridSelectionChanged}},
{text: 'numero', flex: 1, sortable: true, hidden:true, dataIndex: 'num_reqUPReliance'},
{text: 'statut', flex: 1, sortable: true, dataIndex: 'statut_reqUPReliance',tooltip: 'currentStatus',renderer: showUpdated}
],
columnLines: true,
anchor: '100%',
frame: true,
height: 250,
margin: '5 5 5 5',
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
ui: 'footer',
layout: {
pack: 'center'
},
items: [
{
xtype: 'button',
text: 'new',
id:'new_R',
handler: function() {
}
}
]
}]
});
my goal is when I moves the cursor to the icon I want that this message "current status : ..." will be displyed ,
the statut will be displyed related to the value of statut_reqUPReliance
so I think that I should add the test of tooltip
if(record.get("statut_reqUPReliance")=="WaitingAccept") {
metaData.css = ' contactIcon80';
// here I should disply the message of tooltip which is "WaitingAccept"
}
You need to set background-repeat: no-repeat; in your CSS.
In your css file try this:
.contactIcon80{
background-image: url("/UrbanPlanning/theme/images/delete.png") !important;
background-position:center !important;
width: auto !important;
background-repeat: no-repeat;
}
I have an item like so (JSFiddle Demo):
{
region: 'west',
title: 'Instead of toolbar',
collapsible: true,
width: 250,
tbar: [{
xtype: 'button',
text: 'Button',
style: {
background: 'green'
},
handler: function() {}
}]
}
I want my tbar instead of the title like (1->2)
I tried to remove title but it's not working. How to do that thanks :).
Get rid of the header and add the same collapse tool to the toolbar:
{
region: 'west',
collapsible: true,
header: false,
width: 250,
tbar: [
{
xtype: 'button',
text: 'Button',
style: {
background: 'green'
},
handler: function (){}
},
'->',
{
type: 'left',
xtype: 'tool',
handler: function(t) {
this.up('panel').collapse();
}
}
]
}