Results 1 to 4 of 4

Thread: EditorGrid inactive after calling it the second time

  1. #1

    Question EditorGrid inactive after calling it the second time

    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:

    Code:
    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.

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    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

  3. #3

    Default

    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:

    PHP Code:
    // ------------------------------------------------------------------- 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(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 (btntext) {
                    if (
    btn == 'ok') {
                        var 
    redirect 'index.php';
                        
    window.location redirect;
                    }
                });
            },

            
    failure: function (formaction) {
                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 (formaction) {
                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 rekordw...');
        }
    }

    function 
    deleteNewsGroups(btn) {

        if (
    btn == 'yes') {
            var 
    selections newsGroupGrid.selModel.getSelections();
            var 
    newsGr = [];
            for (
    0newsGroupGrid.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: {
                    
    idsencoded_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 rekordw.');
                        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: {
                
    width350
            
    },
            
    frametrue,
            
    items: [{
                
    fieldLabel'Nazwa',
                
    name'ng_title',
                
    id'ng_title',
                
    allowBlankfalse
            
    },
            {
                
    fieldLabel'Opis',
                
    xtype'textarea',
                
    id'ng_content',
                
    name'ng_content',
                
    width350,
                
    height60
            
    }],
            
    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',
                
    closabletrue,
                
    width490,
                
    height180,
                
    plaintrue,
                
    layout'fit',
                
    itemsnewsGroupForm
            
    });
        }

        
    newsGroupGrid = new Ext.grid.EditorGridPanel({
            
    autoDestroyfalse,
            
    columnLinestrue,
            
    dsnewsGroupDS,
            
    cmnewsGroupCM,
            
    enableColLocktrue,
            
    clicksToEdit2,
            
    view: new Ext.grid.GridView({
                
    forceFittrue,
                
    enableGroupingfalse,
            }),
            
    selModel: new Ext.grid.RowSelectionModel({
                
    singleSelectfalse
            
    }),
            
    tbar: [{
                
    text'Dodaj grup?',
                
    tooltip'Dodaj now? grup? aktualno?ci',
                
    iconCls'add',
                
    handlerdisplayNewsAddGroup
            
    },
            {
                
    text'Usu? zaznaczone',
                
    tooltip'Usu? zaznaczone rekordy',
                
    iconCls'remove',
                
    handlerconfirmDeleteNewsGroups
            
    },
            {
                
    xtype'tbseparator'
            
    },
            {
                
    text'Od?wie?',
                
    tooltip'Od?wie? zawarto?? tabeli',
                
    handler: function () {
                    
    newsGroupDS.reload();
                }
            }],
        });


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

            
    items: [{
                
    layout'fit',
                
    flex1.2,
                
    items: [newsGroupGrid]
            }]

        });


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

    }

    function 
    news_new() {

        
    newsFormPanel = new Ext.FormPanel({

            
    standardSubmittrue,
            
    defaultType'textfield',
            
    defaults: {
                
    width550
            
    },
            
    frametrue,
            
    items: [{
                
    fieldLabel'Tytu?',
                
    name'n_title',
                
    id'n_title',
                
    allowBlankfalse
            
    },
            {
                
    fieldLabel'Podtytu?',
                
    name'n_subtitle',
                
    id'n_subtitle',
                
    allowBlanktrue
            
    },
            {
                
    xtype'datefield',
                
    width160,
                
    format'Y-m-d',
                
    fieldLabel'Publikuj od',
                
    name'n_startdt',
                
    id'n_startdt',
            },
            {
                
    xtype'datefield',
                
    width160,
                
    format'Y-m-d',
                
    fieldLabel'Publikuj do',
                
    name'n_enddt',
                
    id'n_enddt',
            },
            {
                
    xtype'htmleditor',
                
    id'n_content',
                
    name'n_content',
                
    fieldLabel'Tre??',
                
    width550,
                
    height300
            
    }],

        });


        
    MainPanel.add({
            
    id'news_new',
            
    title'Nowa aktualno??',
            
    closabletrue,
            
    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',
            
    readernewsGroupDR,
            
    sortInfo: {
                
    field'group_name',
                
    direction"ASC"
            
    }
        });

        
    newsGroupCM = new Ext.grid.ColumnModel({
            
    columns: [{
                
    readOnlytrue,
                
    header'Id',
                
    dataIndex'group_id',
                
    width10,
                
    hiddentrue
            
    },
            {
                
    header'Nazwa',
                
    readOnlytrue,
                
    dataIndex'group_name',
                
    width20,
                
    hiddenfalse,
                
    editor: new Ext.form.TextField({
                    
    allowBlankfalse,
                    
    maxLength255,
                    
    maskRe: /([a-zA-Z0-9\s]+)$/
                })

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

            }]
        });

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

        
    //-- MAIN PANEL
        
    MainPanel = new Ext.TabPanel({
            
    id'mainPanel',
            
    activeItemInfoTab,
            
    region'center',
            
    splittrue,
            
    margins'0 5 0 0',
            
    enableTabScrolltrue,
            
    defaults: {
                
    autoScrolltrue
            
    },
            
    items: [InfoTab],
        });

        
    navContentTree = new Ext.tree.TreePanel({
            
    useArrowstrue,
            
    autoScrolltrue,
            
    animatetrue,
            
    enableDDtrue,
            
    containerScrolltrue,
            
    borderfalse,
            
    root: {
                
    nodeType'async',
                
    text'Tre?? strony',
                
    draggablefalse,
                
    id'source',
                
    children: [{
                    
    text'Aktualno?ci',
                    
    leaffalse,
                    
    children: [{
                        
    text'Dodaj now?',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('news_new')
                            },
                        }
                    },
                    {
                        
    text'Lista aktualno?ci',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('news_list')
                            },
                        }
                    },
                    {
                        
    text'Zarz?dzaj grupami',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('news_groups')
                            },
                        }
                    }]
                } {
                    
    text'Pliki',
                    
    leaffalse,
                    
    children: [{
                        
    text'Dodaj nowy',
                        
    leaftrue,
                    },
                    {
                        
    text'Zarz?dzaj plikami',
                        
    leaftrue,
                    }]
                }]
            },
            
    rootVisiblefalse,
        });

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

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

        });

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

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

        
    //-- NAV PANEL
        
    NavPanel = new Ext.Panel({
            
    region'west',
            
    title'Nawigacja',
            
    collapsibletrue,
            
    width250,
            
    minSize220,
            
    maxSize280,
            
    margins'0 5 0 0',
            
    layout: {
                
    type'accordion',
                
    animatefalse
            
    },
            
    items: [navContentnavAdminnavStatsnavHelp]
        });

        
    // -- HEADER     
        
    Header_Head = new Ext.BoxComponent({
            
    region'north',
            
    height50,
            
    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',
            
    height30,
            
    width80,
            
    items: [HMB_Logout],
        });

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

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

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


        
    // -- FOOTER
        
    Footer = new Ext.BoxComponent({
            
    region'south',
            
    height20,
            
    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: [HeaderNavPanelMainPanelFooter]
        });

    }); 
    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

  4. #4

    Default

    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)

    PHP Code:
    // ------------------------------------------------------------------- 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(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 (btntext) {
                    if (
    btn == 'ok') {
                        var 
    redirect 'index.php';
                        
    window.location redirect;
                    }
                });
            },

            
    failure: function (formaction) {
                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 (formaction) {
                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 rekordw...');
        }
    }

    function 
    deleteNewsGroups(btn) {

        if (
    btn == 'yes') {
            var 
    selections newsGroupGrid.selModel.getSelections();
            var 
    newsGr = [];
            for (
    0newsGroupGrid.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: {
                    
    idsencoded_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 rekordw.');
                        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',
            
    readernewsGroupDR,
            
    sortInfo: {
                
    field'group_name',
                
    direction"ASC"
            
    }
        });

        
    newsGroupCM = new Ext.grid.ColumnModel({
            
    columns: [{
                
    readOnlytrue,
                
    header'Id',
                
    dataIndex'group_id',
                
    width10,
                
    hiddentrue
            
    },
            {
                
    header'Nazwa',
                
    readOnlytrue,
                
    dataIndex'group_name',
                
    width20,
                
    hiddenfalse,
                
    editor: new Ext.form.TextField({
                    
    allowBlankfalse,
                    
    maxLength255,
                    
    maskRe: /([a-zA-Z0-9\s]+)$/
                })

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

            }]
        });

        if (
    newsGroupForm == "undefined" || newsGroupForm == null) {
            
    newsGroupForm = new Ext.FormPanel({
                
    url'func/insert_newsGroup.php',
                
    defaultType'textfield',
                
    defaults: {
                    
    width350
                
    },
                
    frametrue,
                
    items: [{
                    
    fieldLabel'Nazwa',
                    
    name'ng_title',
                    
    id'ng_title',
                    
    allowBlankfalse
                
    },
                {
                    
    fieldLabel'Opis',
                    
    xtype'textarea',
                    
    id'ng_content',
                    
    name'ng_content',
                    
    width350,
                    
    height60
                
    }],
                
    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',
                
    closabletrue,
                
    width490,
                
    height180,
                
    plaintrue,
                
    layout'fit',
                
    itemsnewsGroupForm
            
    });
        }

        
    newsGroupGrid = new Ext.grid.EditorGridPanel({
            
    columnLinestrue,
            
    dsnewsGroupDS,
            
    cmnewsGroupCM,
            
    enableColLocktrue,
            
    clicksToEdit2,
            
    view: new Ext.grid.GridView({
                
    forceFittrue,
                
    enableGroupingfalse,
            }),
            
    selModel: new Ext.grid.RowSelectionModel({
                
    singleSelectfalse
            
    }),
            
    tbar: [{
                
    text'Dodaj grup?',
                
    tooltip'Dodaj now? grup? aktualno?ci',
                
    iconCls'add',
                
    handlerdisplayNewsAddGroup
            
    },
            {
                
    text'Usu? zaznaczone',
                
    tooltip'Usu? zaznaczone rekordy',
                
    iconCls'remove',
                
    handlerconfirmDeleteNewsGroups
            
    },
            {
                
    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',
                
    flex1.2,
                
    items: [newsGroupGrid]
            }]

        });


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

        
    newsGroupDS.load();

    }

    function 
    news_new() {

        
    newsFormPanel = new Ext.FormPanel({

            
    standardSubmittrue,
            
    defaultType'textfield',
            
    defaults: {
                
    width550
            
    },
            
    frametrue,
            
    items: [{
                
    fieldLabel'Tytu?',
                
    name'n_title',
                
    id'n_title',
                
    allowBlankfalse
            
    },
            {
                
    fieldLabel'Podtytu?',
                
    name'n_subtitle',
                
    id'n_subtitle',
                
    allowBlanktrue
            
    },
            {
                
    xtype'datefield',
                
    width160,
                
    format'Y-m-d',
                
    fieldLabel'Publikuj od',
                
    name'n_startdt',
                
    id'n_startdt',
            },
            {
                
    xtype'datefield',
                
    width160,
                
    format'Y-m-d',
                
    fieldLabel'Publikuj do',
                
    name'n_enddt',
                
    id'n_enddt',
            },
            {
                
    xtype'htmleditor',
                
    id'n_content',
                
    name'n_content',
                
    fieldLabel'Tre??',
                
    width550,
                
    height300
            
    }],

        });


        
    MainPanel.add({
            
    id'news_new',
            
    title'Nowa aktualno??',
            
    closabletrue,
            
    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 OBIEKTW ------------------------------------------------
        //--- INFO TAB
        
    InfoTab = new Ext.Panel({
            
    closablefalse,
            
    id'Witaj',
            
    title'Witaj...',
            
    //html: 'Dzisiaj jest...',
            
    autoLoad''
        
    });

        
    //-- MAIN PANEL
        
    MainPanel = new Ext.TabPanel({
            
    id'mainPanel',
            
    activeItemInfoTab,
            
    region'center',
            
    splittrue,
            
    margins'0 5 0 0',
            
    enableTabScrolltrue,
            
    defaults: {
                
    autoScrolltrue
            
    },
            
    items: [InfoTab],
        });

        
    navContentTree = new Ext.tree.TreePanel({
            
    useArrowstrue,
            
    autoScrolltrue,
            
    animatetrue,
            
    enableDDtrue,
            
    containerScrolltrue,
            
    borderfalse,
            
    root: {
                
    nodeType'async',
                
    text'Tre?? strony',
                
    draggablefalse,
                
    id'source',
                
    children: [{
                    
    text'Aktualno?ci',
                    
    leaffalse,
                    
    children: [{
                        
    text'Dodaj now?',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('news_new')
                            },
                        }
                    },
                    {
                        
    text'Lista aktualno?ci',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('Lista aktualno?ci')
                            },
                        }
                    },
                    {
                        
    text'Zarz?dzaj grupami',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('news_groups')
                            },
                        }
                    }]
                },
                {
                    
    text'Artyku?y',
                    
    leaffalse,
                    
    children: [{
                        
    text'Dodaj nowy',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('Nowy artyku?')
                            },
                        }
                    },
                    {
                        
    text'Lista artyku?w',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('Lista artyku?w')
                            },
                        }
                    },
                    {
                        
    text'Zarz?dzaj kategoriami',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('Kaegorie artyku?w')
                            },
                        }
                    },
                    {
                        
    text'Zarz?dzaj subkategoriami',
                        
    leaftrue,
                        
    listeners: {
                            
    click: function () {
                                
    openNewTab('Subkategorie artyku?w')
                            },
                        }
                    }]
                },
                {
                    
    text'Pliki',
                    
    leaffalse,
                    
    children: [{
                        
    text'Dodaj nowy',
                        
    leaftrue,
                    },
                    {
                        
    text'Zarz?dzaj plikami',
                        
    leaftrue,
                    }]
                }]
            },
            
    rootVisiblefalse,
        });

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

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

        });

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

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

        
    //-- NAV PANEL
        
    NavPanel = new Ext.Panel({
            
    region'west',
            
    title'Nawigacja',
            
    collapsibletrue,
            
    width250,
            
    minSize220,
            
    maxSize280,
            
    margins'0 5 0 0',
            
    layout: {
                
    type'accordion',
                
    animatefalse
            
    },
            
    items: [navContentnavAdminnavStatsnavHelp]
        });

        
    // -- HEADER     
        
    Header_Head = new Ext.BoxComponent({
            
    region'north',
            
    height50,
            
    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',
            
    height30,
            
    width80,
            
    items: [HMB_Logout],
        });

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

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

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


        
    // -- FOOTER
        
    Footer = new Ext.BoxComponent({
            
    region'south',
            
    height20,
            
    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: [HeaderNavPanelMainPanelFooter]
        });

    }); 
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •