PDA

View Full Version : EditorGrid inactive after calling it the second time



pi_wo
14 Dec 2009, 3:40 AM
Hi,

I'm probably doubling some of the previous posts, but I don't know how to name the problem in only few words, so I couldn't find any solution through search engine.

Code at first:




function news_groups(){

newsGroupDS.load();

newsGroupForm = new Ext.FormPanel({
url:'func/insert_newsGroup.php',
defaultType: 'textfield',
defaults: {width: 350},
frame:true,
items: [{
fieldLabel: 'Nazwa',
name: 'ng_title',
id: 'ng_title',
allowBlank:false
},
{
fieldLabel: 'Opis',
xtype: 'textarea',
id: 'ng_content',
name: 'ng_content',
width: 350,
height: 60
}],
buttons: [{
text: 'Zapisz',
handler: function(){
insertNewsGroup();
}
},
{
text: 'Wyczy??',
handler: function(){
newsGroupForm.getForm().reset();
}
}]

});

if(newsAddNewGroupWindow == "undefined" || newsAddNewGroupWindow == null){
newsAddNewGroupWindow = new Ext.Window({
closeAction: 'hide',
id: 'newsAddNewGroupWindow',
title: 'Nowa grupa aktualno?ci',
closable:true,
width: 490,
height: 180,
plain:true,
layout: 'fit',
items: newsGroupForm
});
}

newsGroupGrid = new Ext.grid.EditorGridPanel({
autoDestroy: false,
columnLines: true,
ds: newsGroupDS,
cm: newsGroupCM,
enableColLock:true,
clicksToEdit: 2,
view: new Ext.grid.GridView({
forceFit: true,
enableGrouping: false,
}),
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
tbar: [
{
text: 'Dodaj grup?',
tooltip: 'Dodaj now? grup? aktualno?ci',
iconCls:'add',
handler: displayNewsAddGroup
},{
text: 'Usu? zaznaczone',
tooltip: 'Usu? zaznaczone rekordy',
iconCls:'remove',
handler: confirmDeleteNewsGroups
},
{xtype: 'tbseparator'},
{
text: 'Od?wie?',
tooltip: 'Od?wie? zawarto?? tabeli',
handler: function(){newsGroupDS.reload();}
}
],
});


newsGroupPanel = new Ext.Panel({
autoDestroy: false,
layout:'vbox',
layoutConfig: {
align : 'stretch',
pack : 'start',
},

items:[
{
layout: 'fit',
flex: 1.2,
items: [newsGroupGrid]
}
]

});


MainPanel.add({
autoDestroy: false,
closeAction: 'hide',
id: 'news_groups',
title: 'Grupy aktualno?ci',
closable: true,
layout: 'fit',
items: [newsGroupPanel]
}).show();

}
///////////
MainPanel = new Ext.TabPanel({
id: 'mainPanel',
activeItem: InfoTab,
region: 'center',
split: true,
margins: '0 5 0 0',
enableTabScroll:true,
defaults: {autoScroll:true},
items: [InfoTab],
});
//////////

Ext.onReady(function(){


Ext.QuickTips.init();

newsGroupDR = new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'group_id'},
[
{name: 'group_id', type: 'int', mapping: 'group_id'},
{name: 'group_name', type: 'string', mapping: 'group_name'},
{name: 'group_text', type: 'string', mapping: 'group_text'},
]
);

newsGroupDS = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'func/get_newsGroupDS.php', // File to connect to
method: 'POST'
}),
id: 'newsGroupDS',
reader: newsGroupDR,
sortInfo:{field: 'group_name', direction: "ASC"}
});

newsGroupCM = new Ext.grid.ColumnModel({
columns: [{
readOnly: true,
header: 'Id',
dataIndex: 'group_id',
width: 10,
hidden: true
},{
header: 'Nazwa',
readOnly: true,
dataIndex: 'group_name',
width: 20,
hidden: false,
editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 255,
maskRe: /([a-zA-Z0-9\s]+)$/
})

},{
readOnly: true,
header: 'Opis',
dataIndex: 'group_text',
editor: new Ext.form.TextField({
allowBlank: false,
maskRe: /([a-zA-Z0-9\s]+)$/
})

}]
});

The idea is pretty simple, function creates and displays the set of objects in the 'MainPanel' as a new tab. One of the objects is EditorGridPanel. Everything works great, but once I edit any of the columns in the grid, close the tab, and than open it again, the column isn't editable anymore.

I understand that I might have messed up something with declaration of variables/objects that are connected somehow to the editor objects. Can you please show where my concept fails? :) I'm not a programmer, so some things are for me not as clear as they should be.

14 Dec 2009, 6:20 AM
First: you are globally scoping your variables. This is a no-no! Read up on the var keyword.

Second: closing a tab means destroying the component. Thus you need to recreate the GridPanel if you're going to re-add it to the tab. Read: http://www.extjs.com/learn/Ext_2_Overview

pi_wo
16 Dec 2009, 8:02 AM
Hi,

Thanks for your reply,

Probably I should put the whole code in the first to show what I actualy understand pretty good and what not so well.

So here it is:


// ------------------------------------------------------------------- VAR ---------------------------------------------------
// Basic
var Footer;
var Header;
var Header_Menu;
var Header_MenuBar;
var Header_MenuBar2;
var HMB_Logout;
var Header_Head;
var NavPanel;
var navHelp;
var navStats;
var navContent;
var navAdmin;
var navContentTree;
var MainPanel;
var InfoTab;

// Modules
var newsFormPanel;

var newsGroupPanel;
var newsGroupGrid;
var newsGroupForm;
var newsAddNewGroupWindow;

// Datastores
var newsGroupDR;
var newsGroupDS;
var newsGroupCM;

// -------------------------------------------------------------------FUNC---------------------------------------------------
// RoundMe


function roundMe(v) {
return Math.round(v * 100) / 100;
}

// user_logout


function user_logout() {

Ext.Ajax.request({
method: 'POST',
url: 'func/logout.php',
success: function () {
Ext.Msg.alert('Wylogowanie', 'Jeste? poprawnie wylogowany!', function (btn, text) {
if (btn == 'ok') {
var redirect = 'index.php';
window.location = redirect;
}
});
},

failure: function (form, action) {
if (action.failureType == 'server') {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('B??d podczas wylogowywania...', obj.errors.reason);
} else {
Ext.Msg.alert('Ostrze?enie!', 'Brak dost?pu do serwera : ' + action.response.responseText);
}

}
});

}

// Tab loader

function openNewTab(tab_id) {

if (MainPanel.findById(tab_id)) {
MainPanel.activate(tab_id);
} else {
switch (tab_id) {

case 'news_new':
news_new();
break;

case 'news_groups':
news_groups();
break;

default:
MainPanel.activate('Witaj');

}
}

}

function displayNewsAddGroup() {
newsAddNewGroupWindow.show();
}

function insertNewsGroup() {

newsGroupForm.getForm().submit({
method: 'POST',
waitTitle: '??czenie z serwerem...',
waitMsg: 'Zapisywanie danych...',

success: function () {
Ext.Msg.alert('Sukces!', 'Nowy grupa aktualno?ci dodana!');
newsAddNewGroupWindow.hide();
newsGroupForm.getForm().reset();
newsGroupDS.reload();
},

failure: function (form, action) {
if (action.failureType == 'server') {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('B??d!', 'B??dne logowanie...', obj.errors.reason);
} else {
Ext.Msg.alert('Ostrze?enie!', 'Brak dost?pu do serwera : ' + action.response.responseText);
}
login.getForm().reset();
}
});
}

function confirmDeleteNewsGroups() {

if (newsGroupGrid.selModel.getCount() == 1) {
Ext.MessageBox.confirm('Czy...', '...na pewno usun?? wybran? grup??', deleteNewsGroups);
} else if (newsGroupGrid.selModel.getCount() > 1) {
Ext.MessageBox.confirm('Czy...', '...na pewno usun?? wybrane grupy?', deleteNewsGroups);
} else {
Ext.MessageBox.alert('Nie zaznaczy?e? ?adnych rekordów...');
}
}

function deleteNewsGroups(btn) {

if (btn == 'yes') {
var selections = newsGroupGrid.selModel.getSelections();
var newsGr = [];
for (i = 0; i < newsGroupGrid.selModel.getCount(); i++) {
newsGr.push(selections[i].json.group_id);
}
var encoded_array = Ext.encode(newsGr);
Ext.Ajax.request({
waitMsg: 'Przetwarzanie danych',
url: 'func/delete_newsGroup.php',
params: {
ids: encoded_array
},
success: function (response) {
var result = eval(response.responseText);
switch (result) {
case 1:
newsGroupDS.reload();
Ext.Msg.alert('Sukces!', 'Wybrane grupa(y) aktualno?ci zosta?y usuni?te.');
break;
default:
Ext.MessageBox.alert('Ostrze?enie!', 'Nie skasowano (wszystkich) wybranych rekordów.');
break;
}
},
failure: function (response) {
var result = response.responseText;
Ext.MessageBox.alert('B??d!', 'Problem z po??czeniem do bazy danych.');
}
});
}

}

// ------------------------------------------------ MOD ---------------------------------------------

function news_groups() {

newsGroupDS.load();

newsGroupForm = new Ext.FormPanel({
url: 'func/insert_newsGroup.php',
defaultType: 'textfield',
defaults: {
width: 350
},
frame: true,
items: [{
fieldLabel: 'Nazwa',
name: 'ng_title',
id: 'ng_title',
allowBlank: false
},
{
fieldLabel: 'Opis',
xtype: 'textarea',
id: 'ng_content',
name: 'ng_content',
width: 350,
height: 60
}],
buttons: [{
text: 'Zapisz',
handler: function () {
insertNewsGroup();
}
},
{
text: 'Wyczy??',
handler: function () {
newsGroupForm.getForm().reset();
}
}]

});

if (newsAddNewGroupWindow == "undefined" || newsAddNewGroupWindow == null) {
newsAddNewGroupWindow = new Ext.Window({
closeAction: 'hide',
id: 'newsAddNewGroupWindow',
title: 'Nowa grupa aktualno?ci',
closable: true,
width: 490,
height: 180,
plain: true,
layout: 'fit',
items: newsGroupForm
});
}

newsGroupGrid = new Ext.grid.EditorGridPanel({
autoDestroy: false,
columnLines: true,
ds: newsGroupDS,
cm: newsGroupCM,
enableColLock: true,
clicksToEdit: 2,
view: new Ext.grid.GridView({
forceFit: true,
enableGrouping: false,
}),
selModel: new Ext.grid.RowSelectionModel({
singleSelect: false
}),
tbar: [{
text: 'Dodaj grup?',
tooltip: 'Dodaj now? grup? aktualno?ci',
iconCls: 'add',
handler: displayNewsAddGroup
},
{
text: 'Usu? zaznaczone',
tooltip: 'Usu? zaznaczone rekordy',
iconCls: 'remove',
handler: confirmDeleteNewsGroups
},
{
xtype: 'tbseparator'
},
{
text: 'Od?wie?',
tooltip: 'Od?wie? zawarto?? tabeli',
handler: function () {
newsGroupDS.reload();
}
}],
});


newsGroupPanel = new Ext.Panel({
autoDestroy: false,
layout: 'vbox',
layoutConfig: {
align: 'stretch',
pack: 'start',
},

items: [{
layout: 'fit',
flex: 1.2,
items: [newsGroupGrid]
}]

});


MainPanel.add({
autoDestroy: false,
closeAction: 'hide',
id: 'news_groups',
title: 'Grupy aktualno?ci',
closable: true,
layout: 'fit',
items: [newsGroupPanel]
}).show();

}

function news_new() {

newsFormPanel = new Ext.FormPanel({

standardSubmit: true,
defaultType: 'textfield',
defaults: {
width: 550
},
frame: true,
items: [{
fieldLabel: 'Tytu?',
name: 'n_title',
id: 'n_title',
allowBlank: false
},
{
fieldLabel: 'Podtytu?',
name: 'n_subtitle',
id: 'n_subtitle',
allowBlank: true
},
{
xtype: 'datefield',
width: 160,
format: 'Y-m-d',
fieldLabel: 'Publikuj od',
name: 'n_startdt',
id: 'n_startdt',
},
{
xtype: 'datefield',
width: 160,
format: 'Y-m-d',
fieldLabel: 'Publikuj do',
name: 'n_enddt',
id: 'n_enddt',
},
{
xtype: 'htmleditor',
id: 'n_content',
name: 'n_content',
fieldLabel: 'Tre??',
width: 550,
height: 300
}],

});


MainPanel.add({
id: 'news_new',
title: 'Nowa aktualno??',
closable: true,
layout: 'fit',
items: [newsFormPanel]
}).show();


}

// ------------------------------------------------------------------- EXT
Ext.onReady(function () {


Ext.QuickTips.init();

Ext.Ajax.on({
"requestcomplete": function () {
Ext.get(document.body).unmask();
},
"beforerequest": function () {
Ext.get(document.body).mask('<img src="ext/resources/images/default/shared/loading-balls.gif">');
},
"requestexception": function () {

}
});


// ------------------------------------------------------------------- DATA STORE/READER ------------------------------------------------
newsGroupDR = new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'group_id'
},
[{
name: 'group_name',
type: 'string',
mapping: 'group_name'
},
{
name: 'group_id',
type: 'int',
mapping: 'group_id'
},
{
name: 'group_text',
type: 'string',
mapping: 'group_text'
},
]);

newsGroupDS = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'func/get_newsGroupDS.php',
// File to connect to
method: 'POST'
}),
id: 'newsGroupDS',
reader: newsGroupDR,
sortInfo: {
field: 'group_name',
direction: "ASC"
}
});

newsGroupCM = new Ext.grid.ColumnModel({
columns: [{
readOnly: true,
header: 'Id',
dataIndex: 'group_id',
width: 10,
hidden: true
},
{
header: 'Nazwa',
readOnly: true,
dataIndex: 'group_name',
width: 20,
hidden: false,
editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 255,
maskRe: /([a-zA-Z0-9\s]+)$/
})

},
{
readOnly: true,
header: 'Opis',
dataIndex: 'group_text',
editor: new Ext.form.TextField({
allowBlank: false,
maskRe: /([a-zA-Z0-9\s]+)$/
})

}]
});

// ------------------------------------------------------------------- DEFINICJE G?ÓWNYCH OBIEKTÓW ------------------------------------------------
//--- INFO TAB
InfoTab = new Ext.Panel({
closable: false,
id: 'Witaj',
title: 'Witaj...',
//html: 'Dzisiaj jest...',
autoLoad: ''
});

//-- MAIN PANEL
MainPanel = new Ext.TabPanel({
id: 'mainPanel',
activeItem: InfoTab,
region: 'center',
split: true,
margins: '0 5 0 0',
enableTabScroll: true,
defaults: {
autoScroll: true
},
items: [InfoTab],
});

navContentTree = new Ext.tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
root: {
nodeType: 'async',
text: 'Tre?? strony',
draggable: false,
id: 'source',
children: [{
text: 'Aktualno?ci',
leaf: false,
children: [{
text: 'Dodaj now?',
leaf: true,
listeners: {
click: function () {
openNewTab('news_new')
},
}
},
{
text: 'Lista aktualno?ci',
leaf: true,
listeners: {
click: function () {
openNewTab('news_list')
},
}
},
{
text: 'Zarz?dzaj grupami',
leaf: true,
listeners: {
click: function () {
openNewTab('news_groups')
},
}
}]
} {
text: 'Pliki',
leaf: false,
children: [{
text: 'Dodaj nowy',
leaf: true,
},
{
text: 'Zarz?dzaj plikami',
leaf: true,
}]
}]
},
rootVisible: false,
});

//--- NAV: Content
navContent = new Ext.Panel({
title: 'Tre?? strony',
collapsed: false,
items: [navContentTree],
});

//--- NAV: Admin
navAdmin = new Ext.Panel({
title: 'Administracja',
html: 'Tre??...',
collapsed: false,

});

navStats = new Ext.Panel({
title: 'Statystyki',
html: 'Tre??...',
collapsed: false,
});

navHelp = new Ext.Panel({
title: 'Pomoc',
html: 'Tre??...',
collapsed: false,
});

//-- NAV PANEL
NavPanel = new Ext.Panel({
region: 'west',
title: 'Nawigacja',
collapsible: true,
width: 250,
minSize: 220,
maxSize: 280,
margins: '0 5 0 0',
layout: {
type: 'accordion',
animate: false
},
items: [navContent, navAdmin, navStats, navHelp]
});

// -- HEADER
Header_Head = new Ext.BoxComponent({
region: 'north',
height: 50,
autoEl: {
tag: 'div',
html: '<div style="float: left;"><a href="http:\\www.test.com" target="_blank">Test</a></div><div style="float: left; font-size: 24px; padding: 10px 0px 0px 10px;">Panel administracyjny: FIRMA TESTOWA</div>'
}
});

// -- BUTTON: Wyloguj
HMB_Logout = new Ext.Button({
text: 'Wyloguj',
region: 'center',
handler: function () {
user_logout();
}
});



// -- MENU: TOOLBAR 2
Header_MenuBar2 = new Ext.Toolbar({
layout: 'border',
region: 'east',
height: 30,
width: 80,
items: [HMB_Logout],
});

Header_MenuBar = new Ext.Toolbar({
layout: 'border',
region: 'center',
height: 30,
items: [],
});

// -- MENU: TOOLBAR
Header_Menu = new Ext.Panel({
layout: 'border',
region: 'center',
items: [Header_MenuBar, Header_MenuBar2]
});

// -- HEADER
Header = new Ext.Panel({
layout: 'border',
region: 'north',
margins: '5 5 5 0',
height: 80,
items: [Header_Head, Header_Menu]
});


// -- FOOTER
Footer = new Ext.BoxComponent({
region: 'south',
height: 20,
autoEl: {
tag: 'div',
html: '<div style="float: right"><span style="font-size: 10px;"> &copy Copyright ....</span></div>'
}
});

// - MAIN VIEWPORT
viewport = new Ext.Viewport({
layout: 'border',
margins: '5 5 5 5',
items: [Header, NavPanel, MainPanel, Footer]
});

});

Thanks for the link, I learnt a lot from it. The variable (or objects if you will) are created each time the function is initiated. So the condition:

''Thus you need to recreate the GridPanel if you're going to re-add it to the tab.''

is generally fulfilled. Still, there is the same problem with the editorGridPanel, that I described above (more less accurately, considering my language skills:)

pi_wo
17 Dec 2009, 1:35 AM
Hi,

Thanks a lot for your reply. To show what I know and what I don't, I'm placing the whole script below (I should probably do that in the first place)


// ------------------------------------------------------------------- VAR ---------------------------------------------------
// Podstawowe
var Footer;
var Header;
var Header_Menu;
var Header_MenuBar;
var Header_MenuBar2;
var HMB_Logout;
var Header_Head;
var NavPanel;
var navHelp;
var navStats;
var navContent;
var navAdmin;
var navContentTree;
var MainPanel;
var InfoTab;

// Modu?: Aktualno?ci
var newsFormPanel;

var newsGroupPanel;
var newsGroupGrid;
var newsGroupForm;
var newsAddNewGroupWindow;

// Datastores
var newsGroupDR;
var newsGroupDS;
var newsGroupCM;

// -------------------------------------------------------------------FUNC---------------------------------------------------
// RoundMe


function roundMe(v) {
return Math.round(v * 100) / 100;
}

// user_logout


function user_logout() {

Ext.Ajax.request({
method: 'POST',
url: 'func/logout.php',
success: function () {
Ext.Msg.alert('Wylogowanie', 'Jeste? poprawnie wylogowany!', function (btn, text) {
if (btn == 'ok') {
var redirect = 'index.php';
window.location = redirect;
}
});
},

failure: function (form, action) {
if (action.failureType == 'server') {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('B??d podczas wylogowywania...', obj.errors.reason);
} else {
Ext.Msg.alert('Ostrze?enie!', 'Brak dost?pu do serwera : ' + action.response.responseText);
}

}
});

}

// Tab loader

function openNewTab(tab_id) {

if (MainPanel.findById(tab_id)) {
MainPanel.activate(tab_id);
} else {
switch (tab_id) {

case 'news_new':
news_new();
break;

case 'news_groups':
news_groups();
break;

default:
MainPanel.activate('Witaj');

}
}

}

function displayNewsAddGroup() {
newsAddNewGroupWindow.show();
}

function insertNewsGroup() {

newsGroupForm.getForm().submit({
method: 'POST',
waitTitle: '??czenie z serwerem...',
waitMsg: 'Zapisywanie danych...',

success: function () {
Ext.Msg.alert('Sukces!', 'Nowy grupa aktualno?ci dodana!');
newsAddNewGroupWindow.hide();
newsGroupForm.getForm().reset();
newsGroupDS.reload();
},

failure: function (form, action) {
if (action.failureType == 'server') {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('B??d!', 'B??dne logowanie...', obj.errors.reason);
} else {
Ext.Msg.alert('Ostrze?enie!', 'Brak dost?pu do serwera : ' + action.response.responseText);
}
login.getForm().reset();
}
});
}

function confirmDeleteNewsGroups() {

if (newsGroupGrid.selModel.getCount() == 1) {
Ext.MessageBox.confirm('Czy...', '...na pewno usun?? wybran? grup??', deleteNewsGroups);
} else if (newsGroupGrid.selModel.getCount() > 1) {
Ext.MessageBox.confirm('Czy...', '...na pewno usun?? wybrane grupy?', deleteNewsGroups);
} else {
Ext.MessageBox.alert('Nie zaznaczy?e? ?adnych rekordów...');
}
}

function deleteNewsGroups(btn) {

if (btn == 'yes') {
var selections = newsGroupGrid.selModel.getSelections();
var newsGr = [];
for (i = 0; i < newsGroupGrid.selModel.getCount(); i++) {
newsGr.push(selections[i].json.group_id);
}
var encoded_array = Ext.encode(newsGr);
Ext.Ajax.request({
waitMsg: 'Przetwarzanie danych',
url: 'func/delete_newsGroup.php',
params: {
ids: encoded_array
},
success: function (response) {
var result = eval(response.responseText);
switch (result) {
case 1:
newsGroupDS.reload();
Ext.Msg.alert('Sukces!', 'Wybrane grupa(y) aktualno?ci zosta?y usuni?te.');
break;
default:
Ext.MessageBox.alert('Ostrze?enie!', 'Nie skasowano (wszystkich) wybranych rekordów.');
break;
}
},
failure: function (response) {
var result = response.responseText;
Ext.MessageBox.alert('B??d!', 'Problem z po??czeniem do bazy danych.');
}
});
}

}

// ------------------------------------------------ MOD ---------------------------------------------

function news_groups() {

newsGroupDR = new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'group_id'
},
[{
name: 'group_id',
type: 'int',
mapping: 'group_id'
},
{
name: 'group_name',
type: 'string',
mapping: 'group_name'
},
{
name: 'group_text',
type: 'string',
mapping: 'group_text'
},
]);

newsGroupDS = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'func/get_newsGroupDS.php',
// File to connect to
method: 'POST'
}),
id: 'newsGroupDS',
reader: newsGroupDR,
sortInfo: {
field: 'group_name',
direction: "ASC"
}
});

newsGroupCM = new Ext.grid.ColumnModel({
columns: [{
readOnly: true,
header: 'Id',
dataIndex: 'group_id',
width: 10,
hidden: true
},
{
header: 'Nazwa',
readOnly: true,
dataIndex: 'group_name',
width: 20,
hidden: false,
editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 255,
maskRe: /([a-zA-Z0-9\s]+)$/
})

},
{
readOnly: true,
header: 'Opis',
dataIndex: 'group_text',
editor: new Ext.form.TextField({
allowBlank: false,
maskRe: /([a-zA-Z0-9\s]+)$/
})

}]
});

if (newsGroupForm == "undefined" || newsGroupForm == null) {
newsGroupForm = new Ext.FormPanel({
url: 'func/insert_newsGroup.php',
defaultType: 'textfield',
defaults: {
width: 350
},
frame: true,
items: [{
fieldLabel: 'Nazwa',
name: 'ng_title',
id: 'ng_title',
allowBlank: false
},
{
fieldLabel: 'Opis',
xtype: 'textarea',
id: 'ng_content',
name: 'ng_content',
width: 350,
height: 60
}],
buttons: [{
text: 'Zapisz',
handler: function () {
insertNewsGroup();
}
},
{
text: 'Wyczy??',
handler: function () {
newsGroupForm.getForm().reset();
}
}]

});
}

if (newsAddNewGroupWindow == "undefined" || newsAddNewGroupWindow == null) {
newsAddNewGroupWindow = new Ext.Window({
closeAction: 'hide',
id: 'newsAddNewGroupWindow',
title: 'Nowa grupa aktualno?ci',
closable: true,
width: 490,
height: 180,
plain: true,
layout: 'fit',
items: newsGroupForm
});
}

newsGroupGrid = new Ext.grid.EditorGridPanel({
columnLines: true,
ds: newsGroupDS,
cm: newsGroupCM,
enableColLock: true,
clicksToEdit: 2,
view: new Ext.grid.GridView({
forceFit: true,
enableGrouping: false,
}),
selModel: new Ext.grid.RowSelectionModel({
singleSelect: false
}),
tbar: [{
text: 'Dodaj grup?',
tooltip: 'Dodaj now? grup? aktualno?ci',
iconCls: 'add',
handler: displayNewsAddGroup
},
{
text: 'Usu? zaznaczone',
tooltip: 'Usu? zaznaczone rekordy',
iconCls: 'remove',
handler: confirmDeleteNewsGroups
},
{
xtype: 'tbseparator'
},
{
text: 'Od?wie?',
tooltip: 'Od?wie? zawarto?? tabeli',
handler: function () {
newsGroupDS.reload();
}
}],
});


newsGroupPanel = new Ext.Panel({
layout: 'vbox',
layoutConfig: {
align: 'stretch',
pack: 'start',
},

items: [{
layout: 'fit',
flex: 1.2,
items: [newsGroupGrid]
}]

});


MainPanel.add({
closeAction: 'hide',
id: 'news_groups',
title: 'Grupy aktualno?ci',
closable: true,
layout: 'fit',
items: [newsGroupPanel]
}).show();

newsGroupDS.load();

}

function news_new() {

newsFormPanel = new Ext.FormPanel({

standardSubmit: true,
defaultType: 'textfield',
defaults: {
width: 550
},
frame: true,
items: [{
fieldLabel: 'Tytu?',
name: 'n_title',
id: 'n_title',
allowBlank: false
},
{
fieldLabel: 'Podtytu?',
name: 'n_subtitle',
id: 'n_subtitle',
allowBlank: true
},
{
xtype: 'datefield',
width: 160,
format: 'Y-m-d',
fieldLabel: 'Publikuj od',
name: 'n_startdt',
id: 'n_startdt',
},
{
xtype: 'datefield',
width: 160,
format: 'Y-m-d',
fieldLabel: 'Publikuj do',
name: 'n_enddt',
id: 'n_enddt',
},
{
xtype: 'htmleditor',
id: 'n_content',
name: 'n_content',
fieldLabel: 'Tre??',
width: 550,
height: 300
}],

});


MainPanel.add({
id: 'news_new',
title: 'Nowa aktualno??',
closable: true,
layout: 'fit',
items: [newsFormPanel]
}).show();


}

// ------------------------------------------------------------------- EXT
Ext.onReady(function () {


Ext.QuickTips.init();

Ext.Ajax.on({
"requestcomplete": function () {
Ext.get(document.body).unmask();
},
"beforerequest": function () {
Ext.get(document.body).mask('<img src="ext/resources/images/default/shared/loading-balls.gif">');
},
"requestexception": function () {

}
});


// ------------------------------------------------------------------- DATA STORE/READER ------------------------------------------------


// ------------------------------------------------------------------- DEFINICJE G?ÓWNYCH OBIEKTÓW ------------------------------------------------
//--- INFO TAB
InfoTab = new Ext.Panel({
closable: false,
id: 'Witaj',
title: 'Witaj...',
//html: 'Dzisiaj jest...',
autoLoad: ''
});

//-- MAIN PANEL
MainPanel = new Ext.TabPanel({
id: 'mainPanel',
activeItem: InfoTab,
region: 'center',
split: true,
margins: '0 5 0 0',
enableTabScroll: true,
defaults: {
autoScroll: true
},
items: [InfoTab],
});

navContentTree = new Ext.tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
root: {
nodeType: 'async',
text: 'Tre?? strony',
draggable: false,
id: 'source',
children: [{
text: 'Aktualno?ci',
leaf: false,
children: [{
text: 'Dodaj now?',
leaf: true,
listeners: {
click: function () {
openNewTab('news_new')
},
}
},
{
text: 'Lista aktualno?ci',
leaf: true,
listeners: {
click: function () {
openNewTab('Lista aktualno?ci')
},
}
},
{
text: 'Zarz?dzaj grupami',
leaf: true,
listeners: {
click: function () {
openNewTab('news_groups')
},
}
}]
},
{
text: 'Artyku?y',
leaf: false,
children: [{
text: 'Dodaj nowy',
leaf: true,
listeners: {
click: function () {
openNewTab('Nowy artyku?')
},
}
},
{
text: 'Lista artyku?ów',
leaf: true,
listeners: {
click: function () {
openNewTab('Lista artyku?ów')
},
}
},
{
text: 'Zarz?dzaj kategoriami',
leaf: true,
listeners: {
click: function () {
openNewTab('Kaegorie artyku?ów')
},
}
},
{
text: 'Zarz?dzaj subkategoriami',
leaf: true,
listeners: {
click: function () {
openNewTab('Subkategorie artyku?ów')
},
}
}]
},
{
text: 'Pliki',
leaf: false,
children: [{
text: 'Dodaj nowy',
leaf: true,
},
{
text: 'Zarz?dzaj plikami',
leaf: true,
}]
}]
},
rootVisible: false,
});

//--- NAV: Content
navContent = new Ext.Panel({
title: 'Tre?? strony',
collapsed: false,
items: [navContentTree],
});

//--- NAV: Admin
navAdmin = new Ext.Panel({
title: 'Administracja',
html: 'Tre??...',
collapsed: false,

});

navStats = new Ext.Panel({
title: 'Statystyki',
html: 'Tre??...',
collapsed: false,
});

navHelp = new Ext.Panel({
title: 'Pomoc',
html: 'Tre??...',
collapsed: false,
});

//-- NAV PANEL
NavPanel = new Ext.Panel({
region: 'west',
title: 'Nawigacja',
collapsible: true,
width: 250,
minSize: 220,
maxSize: 280,
margins: '0 5 0 0',
layout: {
type: 'accordion',
animate: false
},
items: [navContent, navAdmin, navStats, navHelp]
});

// -- HEADER
Header_Head = new Ext.BoxComponent({
region: 'north',
height: 50,
autoEl: {
tag: 'div',
html: '<div style="float: left;"><a href="http:\\www.firmatestowa.pl" target="_blank"><img src="images/logo_firmy.png" alt="NAZWA FIRMY"></a></div><div style="float: left; font-size: 24px; padding: 10px 0px 0px 10px;">Panel administracyjny: FIRMA TESTOWA</div>'
}
});

// -- BUTTON: Wyloguj
HMB_Logout = new Ext.Button({
text: 'Wyloguj',
region: 'center',
handler: function () {
user_logout();
}
});



// -- MENU: TOOLBAR 2
Header_MenuBar2 = new Ext.Toolbar({
layout: 'border',
region: 'east',
height: 30,
width: 80,
items: [HMB_Logout],
});

Header_MenuBar = new Ext.Toolbar({
layout: 'border',
region: 'center',
height: 30,
items: [],
});

// -- MENU: TOOLBAR
Header_Menu = new Ext.Panel({
layout: 'border',
region: 'center',
items: [Header_MenuBar, Header_MenuBar2]
});

// -- HEADER
Header = new Ext.Panel({
layout: 'border',
region: 'north',
margins: '5 5 5 0',
height: 80,
items: [Header_Head, Header_Menu]
});


// -- FOOTER
Footer = new Ext.BoxComponent({
region: 'south',
height: 20,
autoEl: {
tag: 'div',
html: '<div style="float: right"><span style="font-size: 10px;"> &copy Copyright by Piotr Wo?oszyn, 2009, <a href="mailto:[email protected]">[email protected]</a></span></div>'
}
});

// - MAIN VIEWPORT
viewport = new Ext.Viewport({
layout: 'border',
margins: '5 5 5 5',
items: [Header, NavPanel, MainPanel, Footer]
});

});Anyways, thanks for the link. It helped a lot! When it comes to the solution for my problem it is already it the script. I just defined DR, DS and CM outside Panel-creator function, what affected somehow the editor inside the grid. Its probably obvious for some of you :) but hell, I'm learning :)

Greets.