Results 1 to 2 of 2

Thread: Calling grid as template from external js file

  1. #1

    Default Calling grid as template from external js file

    hi
    I created a js file which hosts a template of the ext grid in a display panel:
    Code:
     
    Ext.onReady(function(){
            var myData = {
                    records1 : records_grid1,
                    records2 : records_grid2
            };
     
            var fields = grid_fields;
     
            // create the data store
            var firstGridStore = new Ext.data.JsonStore({
                    fields : fields,
                    data   : myData,
                    root   : 'records1'
            });
     
            // Column Model shortcut array
            var cols = grid_columns;
     
            /* Further declaration follows but cut for this example*/
     
            var displayPanel = 'displayPanel'+gridID;
     
            //Simple 'border layout' panel to house both grids
             displayPanel = new Ext.Panel({
                    width        : gridWidth,
                    height       : gridHeight,
                    layout       : 'hbox',
                    renderTo     : gridID,
                    defaults     : { flex : 1 }, //auto stretch
                    layoutConfig : { align : 'stretch' },
     
            /* Further declaration follows but cut for this example*/
    In my php file I declare the variables for the grid:

    PHP Code:
     $gridValues "<script type=\"text/javascript\">
                            var records_grid1 = " 
    $this->records_grid1 ";
                            var records_grid2 = " 
    $this->records_grid2 ";
                            var grid_columns = " 
    $this->grid_columns ";
                            var grid_fields = " 
    $this->grid_fields ";
                            var gridID = '" 
    $this->gridID "';
                        </script>
                        <script type=\"text/javascript\" src=\"grid_template.js\"></script>
                        <div id=\"" 
    $this->gridID "\"></div>"
    This allows me to reuse the grid and fill it with my variables from php.

    I'd like to have 2 grids on one page. When I call my php it will call the js template and for the first grid it is perfect.
    If I call the template again on this page, I get two times the last grid.

    I used "gridID" to differ between the grids, the source code looks perfect.

    My understanding is:
    extjs waits until DOM is ready.
    I filled the variables and the ID is unique, so why doesn't the first grid show up? Why does it get overwritten?

    Or is my complete thinking on how to achive that wrong?

  2. #2

    Default

    Does anyone know what could be wrong with it?
    Thanks

Posting Permissions

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