Results 1 to 3 of 3

Thread: dynamic extjs (like php)

  1. #1
    Ext User
    Join Date
    Mar 2009
    Vote Rating

    Default dynamic extjs (like php)

        <title>Editor Grids</title>
        <link rel="stylesheet" type="text/css" href="../../../lib/extjs/resources/css/ext-all.css" />
         <script type="text/javascript" src="../../../lib/extjs/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="../../../lib/extjs/ext-all.js"></script>
    //ommitted codes here
    //ommitted codes here
    grid = new Ext.grid.EditorGridPanel({
                renderTo: document.body,
                title: 'Movie Database',
                enableColumnMove: false,
                store: store,
                clicksToEdit: 2,
                columns: [
                    {header: 'Movie Title', dataIndex: 'title', editor: title_edit},
                    {header: 'Director', dataIndex: 'director', editor: director_edit},
                    {header: 'Released', dataIndex: 'released', renderer: Ext.util.Format.dateRenderer('Y-m-d'), editor: release_edit},
                    {header: 'Genre', dataIndex: 'genre', renderer: genre_name, editor: genre_edit},
                    {header: 'Tagline', dataIndex: 'tagline', editor: tagline_edit}
    //ommitted codes here
    //ommitted codes here
    hello guys,

    i have a php file (containing the code above).
    in the code, i have a grid basically, as can be seen above, i hard coded the parts of the columns config object (header, dataIndex, etc...).
    i have a table in the database containing 5 columns (the ones being displayed in the grid) so everything seems to be fine (as the store queries the table).

    my problem is if i modify the number of columns in the table, i have to modify again (hard-coding again) the above file since it's javascript(?)

    in php i could have done this dynamically i mean i could have used the for each () statement (instead of hard coding every column) to display every column queried from the table.

    is there a way in extjs to do the same thing, not requiring rehard-coding the code every time a change is made in the structure of the backend tables (or by the result set being returned by the query)? or is this a limitation we have to live with using extjs?

    please enlighten me

    thanks a lot guys

  2. #2

  3. #3
    Sencha User's Avatar
    Join Date
    Mar 2007
    DC Area =)
    Vote Rating


    There is no reason why you can't have PHP that generates JavaScript dynamically. Hell, it's been done for many years now.

Posting Permissions

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