extjs gridpanel: ColumnModel becomes null when GridPanel window shows again - extjs

I defined a GridPanel with pre-configured ColumnModel and Store, and put this GridPanel in a Ext.Window; It works fine when this window shows, however, if I close it and show it again, the ColumnModel of GridPanel becomes null so that this GridPanel cannot correctly rendered.
UPDATED (all code)
var stSummary = new Ext.data.JsonStore({ //define the store for Summary_Grid
fields : [
{
name: 'recID'
}, {
name : 'name',
}],
data: []
});
var colModelSummary = { //define the ColumnModel for Summary_Grid
columns:
[
{
header : "ID",
width : 50,
sortable : true,
menuDisabled: true,
dataIndex : 'recID'
},
{
header : "Name",
width : 100,
sortable : true,
menuDisabled: true,
dataIndex : 'name'
}
]
};
var reportConfig = {
id : 'Report_Window',
width : 250,
floating : true,
style : {
opacity : 0.7,
},
title : "Report",
layout: 'fit',
items : [{
xtype: 'tabpanel',
id: 'Report_Tab',
height: 200,
activeTab: 1,
items:
[
{
xtype : 'grid',
store : stSummary,
colModel : new Ext.grid.ColumnModel(colModelSummary),
stripeRows : true,
id : "Summary_Grid",
title : "Summary at",
sm : new Ext.grid.RowSelectionModel({
singleSelect : true
}),
listeners: {
'beforerender': function() {
console.log(this.getColumnModel().getColumnCount());
}
}
},
{
xtype : 'form',
id : 'Report_Form',
title: 'Item Report',
frame : true,
labelAlign : 'left',
bodyStyle : 'padding:2px',
autoScroll: true,
layout : 'column',
items : []
}
]
}],
resizable : {
dynamic : true
}
};
var reportWindow = new Ext.Window(reportConfig);
reportWindow.show();
document.onclick = myClickHandler;
function myClickHandler() {
if(!Ext.getCmp('Report_Window')) {
var reportWindow = new Ext.Window(reportConfig);
}
Ext.getCmp('Report_Window').show();
}
});
and the error:
Uncaught TypeError: Cannot read property 'length' of undefined
Ext.grid.ColumnModel.Ext.extend.getColumnCount ext-all.js:11

I actually just copy pasted your code into my application. I added reportWindow.show() in the end - and it works! Not sure what could be wrong, can you show all code?
Please note that it might be a close/hide problem, do you recreate your window each time?
EDIT:
Try to set closeAction: 'hide' to your window configuration.
Check this for details:
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Window-cfg-closeAction
EDIT #2:
I tested your code again, and it works again! I only corrected several things like extra commas - my resharper suggested it. (It might cause problems in IE) Then I putted it into Ext.onReady - it works! Ext.version == '3.2.1'
Check the whole code:
Ext.onReady(function() {
var stSummary = new Ext.data.JsonStore({
//define the store for Summary_Grid
fields: [
{
name: 'recID'
}, {
name: 'name'
}],
data: []
});
var colModelSummary = {
//define the ColumnModel for Summary_Grid
columns:
[
{
header: "ID",
width: 50,
sortable: true,
menuDisabled: true,
dataIndex: 'recID'
},
{
header: "Name",
width: 100,
sortable: true,
menuDisabled: true,
dataIndex: 'name'
}
]
};
var reportConfig = {
id: 'Report_Window',
width: 250,
floating: true,
style: {
opacity: 0.7
},
title: "Report",
layout: 'fit',
items: [{
xtype: 'tabpanel',
id: 'Report_Tab',
height: 200,
activeTab: 1,
items:
[
{
xtype: 'grid',
store: stSummary,
colModel: new Ext.grid.ColumnModel(colModelSummary),
stripeRows: true,
id: "Summary_Grid",
title: "Summary at",
sm: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
listeners: {
'beforerender': function() {
console.log(this.getColumnModel().getColumnCount());
}
}
},
{
xtype: 'form',
id: 'Report_Form',
title: 'Item Report',
frame: true,
labelAlign: 'left',
bodyStyle: 'padding:2px',
autoScroll: true,
layout: 'column',
items: []
}
]
}],
resizable: {
dynamic: true
}
};
var reportWindow = new Ext.Window(reportConfig);
reportWindow.show();
document.onclick = myClickHandler;
function myClickHandler() {
if (!Ext.getCmp('Report_Window')) {
reportWindow = new Ext.Window(reportConfig);
}
Ext.getCmp('Report_Window').show();
}
});

Related

Extjs4 - Ext.grid.Panel not updated with data inserted into Ext.data.Store using loadData function

I have a listener defined on çhange event for an item filefield in a Panel. Using loadData method, on the Store with id documentGridStore, I am able to insert data into the store (debugger shows store updated) and count printed below correctly gets updated each time. But, the Panel is not getting updated no matter what I do.
Please suggest what is wrong/missing here. I have provided most of the relevant code.
Ext.define('uploadPaperDocumentDialogPanel', {
extend:'Ext.form.Panel',
...,
items: [{
xtype: 'combobox',
name: 'documentType',
id: 'docTypeId',
fieldLabel: getText('label.document.type'),
emptyText: getText('label.select.type'),
store: 'docTypeStore',
displayField: 'key',
valueField: 'value',
allowBlank : false,
selectOnFocus : true,
typeAhead: true,
forceSelection : true,
queryMode:'local',
width: 400
},
{
xtype:'filefield',
buttonText: 'Browse',
msgTarget: 'qtip',
name:'files[]',
id:'fileId',
allowBlank:false,
style: "padding-left: 5px;padding-right: 20px",
width: 275,
listeners: {
change: function(fld, value){
var files = fld.fileInputEl.dom.files;
var names = [];
if(files){
names.push({"documentType": Ext.getCmp('docTypeId').getValue() , "fileName": files[0].name});
Ext.data.StoreManager.lookup('documentGridStore').loadData(names, true);
console.log(Ext.data.StoreManager.lookup('documentGridStore').getCount());
}
}
},
uploadDocumentGrid
}]
});
Ext.define('DocumentGridModel', {
extend: 'Ext.data.Model',
fields:[
{name : 'documentType' , type : 'string'}
,{name : 'fileName',type : 'string'}
]
});
var UploadDocumentStore = Ext.create('Ext.data.Store', {
model: 'DocumentGridModel',
storeId:'documentGridStore',
data:[]
});
var uploadDocumentGrid = Ext.define('DocumentGrid', {
extend:'Ext.grid.Panel'
,alias:'widget.documentGridId',
width: 400,
border:true,
bodyPadding: 0,
title: 'Documents to be uploaded',
id:'documentGridId',
iconCls: 'icon-stipNote',
columnLines: true
,store: Ext.data.StoreManager.lookup('uploadDocumentGridStore')
,initComponent : function() {
this.columns= [
{
header : 'Document Type',
id : 'documentType',
dataIndex : 'doctype',
flex:1,
align:"left",
editable : false,
sortable: false,
hideable: false,
resizable: false,
}, {
header : 'Filename',
id : 'fileName',
dataIndex : 'filename',
flex:1,
align:"left",
sortable: false,
hideable: false,
resizable: false,
editable : false
}
];
this.store=UploadDocumentStore;
this.callParent();
},
reloadGrid : function() {
this.store.reload();
},
viewConfig: {
emptyText: getText('queuegrid.pagingtoolbar.nodatamessage')
}
});
As #Arthur Rubens indicated, I started checking uploadDocumentGrid grid. And guess what that is where the problem was!
dataIndex field in uploadDocumentGrid for both columns was not matching with DocumentGridModel columns.
I updated uploadDocumentGrid as follows and values reflected on UI:
var uploadDocumentGrid = Ext.define('DocumentGrid', {
extend:'Ext.grid.Panel'
,alias:'widget.documentGridId',
width: 400,
border:true,
bodyPadding: 0, // Don't want content to crunch against the borders
title: 'Documents to be uploaded',
id:'documentGridId',
iconCls: 'icon-stipNote',
columnLines: true //INITCOMPONENT
,store: Ext.data.StoreManager.lookup('uploadDocumentGridStore')
,initComponent : function() {
this.columns= [
{
header : 'Document Type',
id : 'documentType',
dataIndex : 'documentType',
flex:1,
align:"left",
editable : false,
sortable: false,
hideable: false,
resizable: false,
}, {
header : 'Filename',
id : 'fileName',
dataIndex : 'fileName',
flex:1,
align:"left",
sortable: false,
hideable: false,
resizable: false,
editable : false
}
];
this.store=UploadDocumentStore;
//finally call the super classes implementation
this.callParent();
},
// RELOADGRID
reloadGrid : function() {
this.store.reload();
},
viewConfig: {
emptyText: getText('queuegrid.pagingtoolbar.nodatamessage')
}
});
I am still learning extjs. Thanks a lot for your help!

GridPanel Columns names changing automatically

I am trying to add a GridPanle into a window. For this i have created a model, store and then created a panel and then adding this panel into window.
Facing issue with Panel column Headers.
The below is the code i am using.
function(orderModel, ex112ServiceResponse) {
var tablePopup = null;
var gridPanel = null;
var gridData = [];
var gridStore = null;
// Creation of data model
Ext.define('StudentDataModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'reasonCode',
mapping: 'reasonCode'
},
{
name: 'reasonCodeDescription',
mapping: 'reasonCodeDescription'
},
{
name: 'refField1',
mapping: 'refField1'
},
{
name: 'orderID',
mapping: 'orderID'
},
{
name: 'orderLineID',
mapping: 'orderLineID'
}
]
});
// Store data
//debugger;
debugger;
for (var index = 0; index < ex112ServiceResponse.objectReasonCode.length; index++) {
gridData.push(ex112ServiceResponse.objectReasonCode[index]);
}
gridStore = Ext.create('Ext.data.Store', {
model: 'StudentDataModel',
data: gridData
});
gridPanel = Ext.create('Ext.grid.Panel', {
id: 'gridId',
layout: 'fit'
store: gridStore,
stripeRows: true,
width: 800,
enableColumnMove: true,
enableColumnResize: true,
autoDestroy: true,
columns: [{
header: "SKU/Item Number",
dataIndex: 'refField1',
id: 'refField1',
//flex: .5,
sortable: true,
hideable: true
}, {
header: "Reason Code",
dataIndex: 'reasonCode',
id: 'reasonCode',
//flex: .5, // property defines the amount of space this column is going to take in the grid container with respect to all.
sortable: true, // property to sort grid column data.
hideable: true // property which allows column to be hidden run time on user request.
}, {
header: "Description",
dataIndex: 'reasonCodeDescription',
id: 'reasonCodeDescription',
//flex: 1,
sortable: true,
hideable: false // this column will not be available to be hidden.
},
{
header: "DO :: DO Line",
dataIndex: 'orderLineID',
id: 'doDoLine',
//flex: .5,
sortable: true,
renderer: function(value, metadata, record, rowIndex, colIndex, store) {
debugger;
var do_DOLine = record.raw.orderID + " :: " + record.raw.orderLineID;
return do_DOLine;
}
}
]
});
tablePopup = new Ext.Window({
title: 'Cancellation Reason Codes',
id: 'crcWin'
width: 800,
closeAction: 'close',
plain: true,
autoDestroy: true,
items: [gridPanel]
});
tablePopup.show();
//Table Creation End
}
The issue is when the code create a popup for the first time. Popup looks good. But when i close the popup and clicks on a button in the second time created popup has issue. Column names have been changed.
Popup1:
Popup2:
Your help will be highly appreciated.
The issue is you have provided id to your extjs component and inside of window you have used config
//There is no close action in docs
closeAction: 'close'//Defaults to: 'destroy'
The closeAction to take when the close header tool is clicked:
destroy : remove the window from the DOM and destroy it and all descendant Components. The window will not be available to be redisplayed via the show method.
hide : hide the window by setting visibility to hidden and applying negative offsets. The window will be available to be redisplayed via the show method.
Note: This behavior has changed! setting does affect the close method which will invoke the appropriate closeAction.
Instead of using id you can use itemId.
In this FIDDLE, I have created a demo using your code. I hope this will help/guide you.
CODE SNIPPET
Ext.application({
name: 'Fiddle',
launch: function () {
function createWindow() { // Creation of data model
Ext.define('StudentDataModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'reasonCode',
mapping: 'reasonCode'
}, {
name: 'reasonCodeDescription',
mapping: 'reasonCodeDescription'
}, {
name: 'refField1',
mapping: 'refField1'
}, {
name: 'orderID',
mapping: 'orderID'
}, {
name: 'orderLineID',
mapping: 'orderLineID'
}]
});
Ext.create('Ext.data.Store', {
storeId: 'gridStore',
model: 'StudentDataModel',
data: [{
reasonCode: '123',
reasonCodeDescription: 'test test',
refField1: 'it just exammple',
orderID: 1234,
orderID: 12345
}, {
reasonCode: '1231',
reasonCodeDescription: 'test1 test',
refField1: '!it just exammple',
orderID: 12341,
orderID: 123451
}]
});
var gridPanel = Ext.create('Ext.grid.Panel', {
layout: 'fit',
store: 'gridStore',
stripeRows: true,
enableColumnMove: true,
enableColumnResize: true,
autoDestroy: true,
//id: 'gridId',
columns: [{
header: "SKU/Item Number",
dataIndex: 'refField1',
//id: 'refField1',
flex: 1,
sortable: true,
hideable: true
}, {
header: "Reason Code",
dataIndex: 'reasonCode',
// id: 'reasonCode',
flex: 1,
sortable: true, // property to sort grid column data.
hideable: true // property which allows column to be hidden run time on user request.
}, {
header: "Description",
dataIndex: 'reasonCodeDescription',
// id: 'reasonCodeDescription',
flex: 1,
sortable: true,
hideable: false // this column will not be available to be hidden.
}, {
header: "DO :: DO Line",
dataIndex: 'orderLineID',
//id: 'doDoLine',
flex: 1,
sortable: true,
renderer: function (value, metadata, record, rowIndex, colIndex, store) {
var do_DOLine = record.raw.orderID + " :: " + record.raw.orderLineID;
return do_DOLine;
}
}]
});
var tablePopup = new Ext.Window({
title: 'Cancellation Reason Codes',
width: window.innerWidth,
//id: 'crcWin',
plain: true,
modal: true,
autoDestroy: true,
closeAction: 'destroy', //If you want to use hide then you need to be show same window instead of new create
// closeAction: 'close', //https://docs.sencha.com/extjs/4.2.6/#!/api/Ext.window.Window-cfg-closeAction
items: [gridPanel]
});
tablePopup.show();
}
Ext.create('Ext.button.Button', {
text: 'Create window',
renderTo: Ext.getBody(),
handler: createWindow
})
}
});

"Ext.getCmp(...) is undefined" in different function

I have Extjs code in view, this is it:
createPanelMC: function() {
this.requiredSign = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
var panel = Ext.create('Ext.form.Panel', {
defaultType: 'textfield',
name: 'nodebPanel',
width: '100%',
layout: {
type: 'auto',
align: 'stretch'
},
items: [{
xtype : 'fieldset',
name : 'modlayanan',
title : 'Data Pelanggan',
layout : 'column',
width : '95%',
margin : '10',
items: [{
xtype : 'textfield',
name : 'nomor',
id : 'nomor',
fieldLabel : 'PSTN',
emptyText : 'Nomor...',
margin : '10 0 0 0',
width : 350,
labelWidth : 100,
afterLabelTextTpl: this.requiredSign
}, {
xtype : 'textfield',
fieldLabel : 'Speedy',
name : 'speedy',
id : 'speedy',
margin : '10 0 10 20',
width : 350,
labelWidth : 100
},
this.createTreePaketExist()
]
}],
dockedItems: [ {
xtype: 'toolbar',
name: 'tbpaketmc',
dock: 'bottom',
items: [ {
text: '<< Back',
action: 'doBack'
},'->', {
text: 'Submit',
action: 'doSubmit'
}
]
}
]
});
return panel;
},
i call nomor dan speedy in this.createTreePaketExist() . This is the this.createTreePaketExist() code:
createTreePaketExist: function() {
var nopstn= Ext.getCmp('nomor').getValue();
var speedy= Ext.getCmp('speedy').getValue();
var storeTree = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
method: 'POST',
url: 'data/newoss_get_paket.php',
params: {
nopstn:nopstn
,speedy:speedy
}
}
});
var groupProduct = Ext.create('Ext.tree.Panel', {
store : storeTree,
name : 'treeProduct',
rootVisible : false,
useArrows : true,
layout :'fit',
margin : '0 0 0 0',
autoScroll : true,
height : 150,
width : '93%',
listeners:
{
checkchange: function(node, checked, eOpts){
node.eachChild(function(n) {
node.cascadeBy(function(n){
n.set('checked', checked);
});
});
p = node.parentNode;
var pChildCheckedCount = 0;
p.suspendEvents();
p.eachChild(function(c) {
if (c.get('checked')) pChildCheckedCount++;
p.set('checked', !!pChildCheckedCount);
});
p.resumeEvents();
}
}
});
return groupProduct;
},
but it gave an error: Ext.getCmp(...) is undefined. Help me, thanks.
Ext.getCmp() is not recommended to use in ExtJS code. Instead you should use
Ext.ComponentQuery.query('#nomor')
Where nomor is id of element.
But To resolve your problem try to call this:
Ext.ComponentQuery.query('textfield[name="nomor"]')
or
Ext.getCmp('#nomor')
if this will not help you then the problem in your code structure. May be piece of code that represents getCmp('nomor') is loaded and invoked before piece of code that represents your nomor code. This problem may occur if you do not use MVC
The createTreePaketExist will be called during component initialisation, it's unlikely the textfields are actually rendered or even initialised properly at this point, best to use the listeners. You could use refs in your controller to get a reference to these fields automatically or you could listen to the afterrender event and then reference the fields.
I have created a fiddle here that shows how to load the store on form submit, you could also do this on the textfield's change events.
Here is the code for reference:
Ext.application({
name: 'Fiddle',
launch: function() {
var panel = Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
defaultType: 'textfield',
name: 'nodebPanel',
width: '100%',
layout: {
type: 'auto',
align: 'stretch'
},
items: [{
xtype: 'fieldset',
name: 'modlayanan',
title: 'Data Pelanggan',
layout: 'column',
width: '95%',
margin: '10',
items: [{
xtype: 'textfield',
name: 'nomor',
id: 'nomor',
fieldLabel: 'PSTN',
emptyText: 'Nomor...',
margin: '10 0 0 0',
width: 350,
labelWidth: 100,
afterLabelTextTpl: this.requiredSign
}, {
xtype: 'textfield',
fieldLabel: 'Speedy',
name: 'speedy',
id: 'speedy',
margin: '10 0 10 20',
width: 350,
labelWidth: 100
}]
}],
dockedItems: [{
xtype: 'toolbar',
name: 'tbpaketmc',
dock: 'bottom',
items: [{
text: '<< Back',
action: 'doBack'
}, '->', {
text: 'Submit',
action: 'doSubmit',
bindForm: true,
handler: function() {
var nopstn = Ext.getCmp('nomor').getValue();
var speedy = Ext.getCmp('speedy').getValue();
if (nopstn != '' && speedy != '') {
var store = Ext.ComponentQuery.query('#treeProduct')[0].getStore();
console.log(store);
store.load({
params: {
nopstn: nopstn,
speedy: speedy
}
});
}
}
}]
}]
});
var storeTree = Ext.create('Ext.data.TreeStore', {
autoLoad: false,
proxy: {
type: 'ajax',
method: 'POST',
url: 'data/newoss_get_paket.php'
}
});
var groupProduct = Ext.create('Ext.tree.Panel', {
renderTo: Ext.getBody(),
store: storeTree,
itemId: 'treeProduct',
name: 'treeProduct',
rootVisible: false,
useArrows: true,
layout: 'fit',
margin: '0 0 0 0',
autoScroll: true,
height: 150,
width: '93%',
listeners: {
checkchange: function(node, checked, eOpts) {
node.eachChild(function(n) {
node.cascadeBy(function(n) {
n.set('checked', checked);
});
});
p = node.parentNode;
var pChildCheckedCount = 0;
p.suspendEvents();
p.eachChild(function(c) {
if (c.get('checked')) pChildCheckedCount++;
p.set('checked', !! pChildCheckedCount);
});
p.resumeEvents();
}
}
});
}
});

How can i get edited row value from Editable Grid in ExtJs?

I've a HTML page with ExtJs editable grid. Edit is working fine, but i want to get Id field value of the edited row, but can't figured it out... i want to populate another array of values with Id, Name and Email field values of edited ROW...
Ext.onReady(function() {
Ext.create('Ext.data.Store', {
storeId:'myArray',
fields:['id','name', 'email'],
data:{'items':[
{"id":"1", "name":"Lisa", "email":"lisa#ArrayData.com"},
{"id":"2", "name":"Bart", "email":"bart#ArrayData.com"},
{"id":"3", "name":"Homer", "email":"home#ArrayData.com"},
{"id":"4", "name":"Marge", "email":"marge#ArrayData.com"}
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'ArrayData',
store: Ext.data.StoreManager.lookup('myArray'),
columns: [
{header: 'Id', dataIndex: 'id'},
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'Email', dataIndex: 'email', flex:1,
editor: {
xtype: 'textfield',
allowBlank: false
}
}
],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners : {
scope: this,
edit: function (theEditor, e, eOpts)
{
console.log();
}
}
})
],
height: 200,
width: 500,
renderTo: Ext.getBody()
});
});
#
#
Thanks #Hariharan and #Dipti for your valuable help... the working code is-
Ext.create('Ext.data.Store', {
storeId:'myArray',
fields:['id','name', 'email'],
data:{'items':[
{"id":"1", "name":"Lisa", "email":"lisa#ArrayData.com"},
{"id":"2", "name":"Bart", "email":"bart#ArrayData.com"},
{"id":"3", "name":"Homer", "email":"home#ArrayData.com"},
{"id":"4", "name":"Marge", "email":"marge#ArrayData.com"}
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
var array_edited=Ext.create('Ext.data.Store', {
storeId:'myArray_edited',
fields:['id','name', 'email'],
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'ArrayData',
store: Ext.data.StoreManager.lookup('myArray'),
columns: [
{header: 'Id', dataIndex: 'id'},
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'Email', dataIndex: 'email', flex:1,
editor: {
xtype: 'textfield',
allowBlank: false
}
}
],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners : {
scope: this,
edit: function(editor, e) {
array_edited.add({
id: e.record.get('id'),
name: e.record.get('name'),
email: e.record.get('email')
});
}
}
})
],
height: 200,
width: 500,
renderTo: Ext.getBody()
});
Ext.create('Ext.grid.Panel', {
title: 'ArrayDataEdited',
store: Ext.data.StoreManager.lookup('myArray_edited'),
columns: [
{header: 'Id', dataIndex: 'id'},
{header: 'Name', dataIndex: 'name'},
{header: 'Email', dataIndex: 'email', flex:1
}
],
selType: 'cellmodel',
height: 200,
width: 500,
renderTo: Ext.getBody()
});
Please refer below answer, i hope it will help you.
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners : {
edit : function(editor, e) {
alert("Edited id value : " + e.record.get('id'));
}
}
})
],
check this, you have gridPanel with three columns , using sm you can select values of editables, after save you can call fnctChange function and use the new values.
hope this will help you.
var gridPanel = new Ext.grid.GridPanel({
region : 'west',
width : 360,
height : 250,
trackMouseOver : false,
disableSelection : true,
autoscroll : true,
loadMask : true,
margins : '3 3 3 0',
sm : sm,
viewConfig : {
forceFit : true
},
store : store,
// grid columns
columns : [ sm, {
id : 'columnNames',
header : "<b>Select the column names to be displayed</b>",
dataIndex : 'columnNames',
renderer : renderColumnNames,
width : 360,
sortable : true
}, { id : 'col1ID',
header : "",
dataIndex : 'Col1',
hidden : true,
sortable : true
}, {
id : 'col2ID',
header : "",
dataIndex : 'Col2',
hidden : true,
sortable : true
}]
});
var settingPanelMsg = " <b>Change save</b><br></br>"
var settingPanel = new Ext.Panel({
region : 'center',
width : 390,
height : 250,
margins : '3 0 3 3',
collapsible : true,
html : settingPanelMsg
})
winSetting = new Ext.Window({
title : 'Customize Your chnage',
layout : 'border',
closable : false,
height : 300,
width : 730,
items : [ gridPanel, settingPanel ],
buttons : [ {
text : 'Close',
handler : function(e, target, panel) {
winLibSetting.close();
}
}, {
text : 'Save',
handler : function() {
if (fnctChange() == true) {
winLibSetting.close();
}
}
} ]
});
winLibSetting.show();
function fnctChange() {
var L1 = sm.getSelections();
for (i = 0; i < L1.length; i++) {
var col1value = L1[i].data.col1ID;
if (L1[i].data.col2ID == true) {
var colName= L1[i].data.columnNames;
Ext.MessageBox.alert(' ',
'colName :'+colName);
}
}
return true;
}

ExtJS : BUtton actions when extending form panel

How can I call the formpanel.getForm() method when I am trying to override the Ext formpanel?
commentsForm = Ext.extend(Ext.form.FormPanel, {
frame: true,
initComponent: function() {
var config = {
frame : true,
autoScroll : true,
labelWidth : 150,
autoWidth : true,
labelPad : 20,
waitMsgTarget: true,
bodyStyle:'padding:0px 15px 15px 15px',
items: [{
xtype : 'fieldset',
title : 'Write Comment',
anchor : '100%',
defaults : {
selectOnFocus: true,
msgTarget: 'side',
xtype: 'textfield',
width : 200
},
items : [{
xtype : 'textarea',
name : 'comment',
allowBlank : false
}, {
name : 'added_by',
allowBlank : false
}, {
xtype : 'myndatefield',
name : 'added_at',
allowBlank : false,
value : new Date()
}]
}],
buttons: [{
text: 'Add',
handler : function() {
// TODO
var classForm = this.getForm();
console.log(this.getForm());
if (classForm.isValid()) {
console.log(classForm.findField("name"));
}
Ext.WindowMgr.hideAll();
}
}, {
text: 'Cancel',
handler : function() {
Ext.WindowMgr.hideAll();
}
}]
};
Ext.apply(this, Ext.apply(this.initialConfig, config));
myn.commentsForm.superclass.initComponent.apply(this);
}
});
First in your code you are extending not overriding...
commentsForm.getForm() is a way to access BasicForm in your FormPanel if you place var at very beggining, however your code is confusing regarding name spaces: myn.commentsForm.superclass.initComponent.apply(this);

Resources