Public feed #891072

eliasp

public text v1 · immutable
Raw Edit
·published 2008-02-04 09:55 UTC
rendered paste body
Ext.namespace('dokuarchiv');

dokuarchiv.application = function() {
        return {
                init: function() {
                        var tabs = new Ext.TabPanel({
                                renderTo: 'innerbody',
                                autoWidth: true,
                                activeTab: 0,
                                frame:true,
                                height: 500,
                                items:[
                                        {contentEl: 'Patienten', title: 'Patienten-Liste', iconCls: 'tab_icon_patienten'},
                                        {contentEl: 'Medien', title: 'Medien-Liste', iconCls: 'tab_icon_medien'},
                                        {contentEl: 'Operationen', title: 'Operations-Liste', iconCls: 'tab_icon_operationen'}
                                        // {contentEl: 'Administration', title: 'Adminstration'}        //will be added on runtime
                                                                                                        //using TabPanel.insert
                                ]

                        });

                        tabs.show();

                        Ext.ux.menu.RangeMenu.prototype.icons = {
                                gt: 'gfx/greater_then.png',
                                lt: 'gfx/less_then.png',
                                eq: 'gfx/equals.png'
                        };

                        Ext.ux.grid.filter.StringFilter.prototype.icon = 'data/gfx/icons/oxygen/16x16/actions/edit-find.png';
                        Ext.ux.grid.filter.DateFilter.prototype.dateFormat = 'Y-m-d';

                        Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

                        var datareader = new Ext.ux.data.BufferedJsonReader({
                                root:                   'data.results.items',
                                versionProperty:        'data.results.version',
                                totalProperty:          'data.total',
                                id:                     'ID'
                                },
                                [{
                                        name:   'ID',           sortType:       'int'
                                },{
                                        name:   'Name',         sortType:       'string'
                                },{
                                        name:   'Vorname',      sortType:       'string'
                                },{
                                        name:   'Geburtsdatum', sortType:       'int'
                                }]
                        );

                        var datastore = new Ext.ux.grid.BufferedStore({
                                autoLoad:       true,
                                bufferSize:     150,
                                url:            'dataproxy.php',
                                reader:         datareader,
                                sortInfo: {field: 'Name', direction: 'ASC'},
                                /*
                                baseParams: {
                                        foo: 'bar',
                                }
                                */
                        });
                        var filters = new Ext.ux.grid.GridFilters({filters:[
                                {type: 'string', dataIndex: 'Name'},
                                {type: 'string', dataIndex: 'Vorname'},
                                {type: 'date', dataIndex: 'Geburtsdatum'}
                        ]});


                        var columnmodel = new Ext.grid.ColumnModel([
                                {dataIndex: 'ID', header: 'ID', hidden: 'true'},
                                {dataIndex: 'Name', header: 'Name'},
                                {dataIndex: 'Vorname', header: 'Vorname'},
                                {dataIndex: 'Geburtsdatum', header: 'Geburtsdatum', align: 'center'}
                        ]);

                        columnmodel.defaultSortable = true;

                        var gridview = new Ext.ux.grid.BufferedGridView({
                                nearLimit:      20,
                                loadMask:       {
                                                        msg: 'Daten werden<br>nachgeladen...'
                                                }
                        });

                        var toolbar = new Ext.ux.BufferedGridToolbar({
                                view:           gridview,
                                displayInfo:    true,
                                displayMsg:     'Zeige {0} - {1} von {2}',
                                emptyMsg:       'Keine Daten anzuzeigen',
                                refreshText:    'Neu laden'
                        });

                        var selectionmodel = new Ext.ux.grid.BufferedRowSelectionModel();

                        var grid = new Ext.grid.GridPanel({
                                id: 'Patienten',
                                ds: datastore,
                                cm: columnmodel,
                                sm: selectionmodel,
                                loadMask: true,
                                view: gridview,
                                plugins: filters,
                                el: 'Patienten',
                                bbar: toolbar
                        });

                        grid.render();
                        datastore.load();


                }
        };
}();

Ext.onReady(dokuarchiv.application.init, dokuarchiv.application);