How can I give this grid expandable rows? -Ext JS - extjs

I have tried just about everything to give this grid expandable rows. Here's my code:
Ext.define('AM.view.metadata.List' ,{
extend: 'Ext.grid.Panel',
alias: 'widget.metadatalist',
title: '<center>Results</center>',
store: 'Metadata',
requires: ['Ext.*'],
collapsible: true,
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
items: [
{ xtype: 'tbtext', text: 'Loading...', itemId: 'recordNumberItem' },
'->',
{ text: 'Print', itemId: 'print' },
'-',
{ text: 'Export', itemId: 'export' }
]
}],
initComponent: function() {
this.columns = [
{header: 'Technical Name', dataIndex: 'TECH_NAME', flex: 4, tdCls: 'grid_cell'},
{header: 'KBE ID', dataIndex: 'KBE_ID', flex: 2, tdCls: 'grid_cell'},
{header: 'KBE Name', dataIndex: 'KBE_NAME', flex: 3, tdCls: 'grid_cell'},
{header: 'View Name', dataIndex: 'VIEW_NAME', flex: 4, tdCls: 'grid_cell'},
{header: 'Database/Schema', dataIndex: 'DB_SCHEMA', flex: 3, tdCls: 'grid_cell'},
{header: 'Privacy', dataIndex: 'PRIVACY_INDICATOR', flex: 3, tdCls: 'grid_cell'}
];
this.callParent(arguments); //Calls the parent method of the current method in order to override
}
});
And here's where I instantiate it in my app.js
{ xtype: 'metadatalist', padding: '5px 5px 5px 5px', height: 430, width: '100%', hidden: true}
I have tried the rowexpander plugin, but I'm not sure if I put it in the right place. If anyone sees a red flag or can help me out with how to implement this rowexpander, I would greatly appreciate it. I've posted several times about this, and so far have received little to no help. I'm using Ext JS 4.1.1
Thank you!

You need to have the rowexpander plugin in the grid configuration and you need to create an XTemplate for the information presented when the row is expanded. Did you try and follow this example?
http://docs.sencha.com/extjs/4.2.1/#!/example/grid/grid-plugins.html

As it turned out, I needed to set my Loader path so that it could find RowExpander.js. Here's what I did:
Ext.Loader.setPath('Ext.ux', 'extjs/examples/ux'); // change this for your environment
Ext.require([ 'Ext.ux.RowExpander' ]);

Related

ExtJS: How to make grid row height grow to fit a block of text?

I have a gridpanel that looks like this:
Defined by:
{
xtype: 'gridpanel',
title: 'Disclaimer questions',
bind: {
store: '{QuestionStore}'
},
columns: [{
xtype: 'gridcolumn',
dataIndex: 'labelText',
text: 'Question text',
flex: 1
}, {
xtype: 'gridcolumn',
dataIndex: 'answerings',
text: 'Answerings',
flex: 1
}, {
xtype: 'gridcolumn',
dataIndex: 'answerText',
text: 'Answer text',
flex: 1
}]
}
How do you make the rows' heights grow to the size of the text rather than have it cut off with "..."?
As of ExtJS 5, on the column definition, include "cellWrap: true".
columns: [{
xtype: 'gridcolumn',
cellWrap: true, // <---------------------------------------
dataIndex: 'labelText',
text: 'Question text',
flex: 1
}, {
xtype: 'gridcolumn',
dataIndex: 'answerings',
text: 'Answerings',
flex: 1
}, {
xtype: 'gridcolumn',
dataIndex: 'answerText',
text: 'Answer text',
flex: 1
}]

ExtJS - autoScroll doesn't show in nested grid

I've been trying to find an answer to this problem for the last 24 hours and couldn't find a way to resolve this. Here it is:
I'm using MVC architecture with ExtJS 4. I have a tabpanel that has some grid as items. When these grids load, they do not have a vertical scrollbar, even though I set autoScroll to 'true' and their content is bigger than the screen can show. Every post I read about this problem was resolved setting the grid's parent layout to 'fit', but, as you can see below, I already done it and still not have a scrollbar... If I define a height to the grid, the scrollbar works perfectly, but I need it to work with different heights...
I belive I might have a overnesting problem, but I just started developing with ExtJS some days ago and it stills a little confusing to me...
The question is: how can I make this structure work with autoScroll?
SO won't let me post an image here as my reputation is lower than 10, so you can find my app's structure here
Please note that I wrote "layout: 'fix'" in the image, but I meant "layout: 'fit'" :)
This is my Main view, which has 2 panels. The 'center' one is where I load the tabpanel that has the grid.
Ext.define('MyApp.view.Main', {
extend: 'Ext.container.Container',
requires:[
// 'Ext.tab.Panel',
// 'Ext.layout.container.Border',
'MyApp.view.Menus'
],
xtype: 'app-main',
layout: {
type: 'border'
},
items: [
{
region: 'north',
xtype: 'panel',
padding: '5 5 0 5',
title: 'MyApp',
items: {
xtype: 'menus'
}
},
{
region: 'center',
itemId: 'centerPanel',
xtype: 'panel',
padding: 5,
layout: 'fit'
}
]
});
This is the view that have the fieldset and the tabpanel as items:
Ext.define('MyApp.view.licencas.List', {
extend: 'Ext.form.Panel',
xtype: 'licencaslist',
title: 'Licenças de software',
border: false,
items: [
{
xtype: 'fieldset',
title: 'Dados do Veículo',
margin: 5,
items: [
{
xtype: 'combobox',
anchor: '100%',
valueField: 'id',
displayField: 'descricao',
store: 'ComboEmpresas',
typeAhead: true,
queryMode: 'local',
name: 'empresa',
fieldLabel: 'Empresa'
},
{
xtype: 'combobox',
editable: false,
valueField: 'id',
displayField: 'descricao',
store: 'ComboSoftwares',
queryMode: 'local',
name: 'software',
fieldLabel: 'Software'
},
{
name: 'valor',
fieldLabel: 'Valor empresa:',
xtype: 'numberfield',
minValue: 0,
maxValue: 100000,
allowDecimals: true,
disabled: true,
},
{
name: 'contrato',
fieldLabel: 'Contrato:',
xtype: 'textfield',
disabled: true,
},
{
name: 'demonstracao',
xtype: 'checkbox',
fieldLabel: 'Demonstração',
disabled: true,
}
]
},
{
xtype: 'licencastabpanel',
border: false,
margin: 5
}
],
initComponent: function() {
this.callParent(arguments)
}
});
And finally this is the grid where I need the autoScroll property...
Ext.define('MyApp.view.licencas.placas.List', {
extend: 'Ext.grid.Panel',
xtype: 'licencasplacaslist',
store: 'EmpresaVeiculos',
border: false,
forceFit: true,
autoScroll: true,
plugins: [new Ext.grid.plugin.CellEditing({
clicksToEdit: 1,
})],
dockedItems: [
{
dock: 'top',
xtype: 'toolbar',
items: [
{
text: 'Alterar todos',
iconCls: 'money-16',
action: 'alterartodos',
xtype: 'button'
},
'->',
{
xtype: 'trigger',
name: 'searchfieldLicencasPlacas',
itemId: 'searchfieldLicencasPlacas',
emptyText: 'Filtrar por placa...',
width: '500px',
hideLabel: true,
selectOnFocus: true,
triggerCls: 'x-form-search-trigger'
}
]
}
],
columns: [
Ext.create('Ext.grid.RowNumberer'),
{
text: "Placa",
dataIndex: 'placa',
width: 70
},
{
text: "Serial",
dataIndex: 'serial',
width: 70
},
{
text: "Condutor",
dataIndex: 'condutor'
},
{
text: "Ativo",
dataIndex: 'ativo',
width: 50
},
{
text: "Data Início",
dataIndex: 'data_inicio',
format: 'd.m.Y',
width: 60
},
{
text: "Data Fim",
dataIndex: 'dt_fim',
format: 'd.m.Y',
width: 60,
editor: {
xtype: 'datefield',
format: 'd.m.Y'
}
},
{
text: "Contrato",
dataIndex: 'contrato',
width: 70,
editor: {
xtype: 'textfield'
}
},
{
text: "Software",
dataIndex: 'valor_software',
renderer: 'usMoney',
width: 70,
editor: {
xtype: 'numberfield',
minValue: 0,
maxValue: 1000,
allowDecimals : true
}
},
{
text: "Comunicação",
dataIndex: 'valor_comunicacao',
renderer: 'usMoney',
width: 70,
editor: {
xtype: 'numberfield',
minValue: 0,
maxValue: 1000,
allowDecimals : true
}
},
{
text: "Comodato",
dataIndex: 'valor_comodato',
renderer: 'usMoney',
width: 70,
editor: {
xtype: 'numberfield',
minValue: 0,
maxValue: 1000,
allowDecimals : true
}
},
{
text: 'Empresa para faturar',
dataIndex: 'fatura',
width: 200,
editor:
{
xtype: 'combobox',
displayField: 'descricao',
valueField: 'descricao',
store: 'ComboFaturas',
name: 'software',
queryMode: 'local'
}
}
],
initComponent: function() {
this.callParent(arguments)
}
});
Please, note that I removed all "layout: 'fit'" (except from the Main view, which has influence over other views) from the code as it wasn't working anyway... :)
Please, let me know if I need to provide you any extra information. I tried to make it easier to understand with the image below.
Thank you guys!
It works as follows:
grid ignores autoScroll config option
grid needs a height, either explicit or controlled by a layout of its parent container
if grid does not have a height, it tries to expand itself vertically according to the number of records loaded in the store so that it does not show the scrollbar
fit layout can only have one item - if it is a grid then its height (and width) is controlled by the size of the parent container
To summarize: If you want a grid to scroll it must have a height.

Extjs adding checkbox to container.viewport

i am new to extjs and i am trying to add a checkbox to my container.viewport gridpanel.
This is my code:
xtype: 'gridpanel',
flex: 2,
autoScroll: true,
title: 'title',
store: 'OutgoingDataStore',
columns: [
{
xtype: 'gridcolumn',
align: 'right',
dataIndex: 'calls_m',
text: 'Calls Monthly'
},
{
xtype: 'checkcolumn',
align: 'right',
dataIndex: 'check',
text: 'check',
}..
without the checkcolumnit works fine, but when i add it the app shows empty page and on the console i see :'Uncaught TypeError: Cannot call method 'substring' of undefined '
It depends on what version you're using. In 4.2.0, the CheckColumn was moved into the core library. If you're using an earlier version (which it seems like you are), then the CheckColumn is just an extension, so you'd need to include it from the examples/ux folder.
In 4.2.0 you would do it like this.
xtype: 'gridpanel',
flex: 2,
autoScroll: true,
title: 'title',
store: 'OutgoingDataStore',
selModel: Ext.create('Ext.selection.CheckboxModel'), // This will add check column
columns: [
{
xtype: 'gridcolumn',
align: 'right',
dataIndex: 'calls_m',
text: 'Calls Monthly'
}
...

RowExpander not working on grid - Ext JS 4.1.1

I have the panel here that displays fine until i try to implement the rowexpander plugin:
Ext.define('AM.view.userlist.List' ,{
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
title: '<center>Results</center>',
store: 'User',
collapsible: true,
plugins: [{
ptype: 'rowexpander',
id: 'rowexpander',
rowBodyTpl : [
'<p>Name <b>{name}</b></p>',
'<p><b>Address {address}</b></p>'
]
}],
collapsible: true,
animCollapse: false,
initComponent: function() {
this.columns = [
{header: 'ID', dataIndex: 'id', flex: 4, tdCls: 'grid_cell'},
{header: 'Name', dataIndex: 'name', flex: 4, tdCls: 'grid_cell'},
{header: 'Address', dataIndex: 'address', flex: 3, tdCls: 'grid_cell'},
{header: 'Phone', dataIndex: 'phone', flex: 3, tdCls: 'grid_cell'}
];
this.callParent(arguments);
//remaining code...
When i attempt to add the plugin, I get this exception:
TypeError: name is undefined
I'm not sure why I can't get it to work. Any ideas?
Try:
...
requires: [
'Path.to.RowExpander'
],
...

extjs gridpanel not showing scrollbars

I am creating a page that only contains a gridpanel, I want my gridpanel to have scrollbars based on the browser size. To do this I am wrapping it in a viewport as discussed here and making sure I specify a layout as discussed here. The grid renders fine but I am not getting any scroll bars. I've tried 'fit', 'border' and 'anchor' layouts but still no luck. The code looks like this:
Ext.create('Ext.Viewport', {
items: [{
region: 'center',
layout: 'fit',
xtype: 'gridpanel',
store: myStore,
loadMask: true,
columns: [{
header: 'Account ID',
dataIndex: 'acct_id',
width: 70
}, {
header: 'First Name',
dataIndex: 'first_name',
width: 120
}, {
header: 'Last Name',
dataIndex: 'last_name',
width: 120
}, {
xtype: 'numbercolumn',
header: 'Account Balance',
dataIndex: 'acct_bal',
width: 70,
renderer: Ext.util.Format.usMoney
}, {
xtype: 'numbercolumn',
header: 'Credit',
dataIndex: 'credit',
width: 70,
renderer: Ext.util.Format.usMoney
}, {
xtype: 'numbercolumn',
header: 'Debt',
dataIndex: 'debt_bal',
width: 70,
renderer: Ext.util.Format.usMoney
}],
}]
});
You should set fit layout to Viewport:
Ext.create('Ext.Viewport', {
layout: 'fit',
items: [...]
});
Setting layout in GridPanel have no effect.

Resources