dynamic Grid columns
<p>I need help with dynamic columns in a DataGrid. I use GenericFrame front-end with PHP backend.</p>

<p>If I use static columns like this:</p>

<pre><code> &lt;? ... ?&gt;
&lt;DataGrid id="DataGrid1" width="100%"&gt;
    &lt;columns&gt;
        &lt;DataGridColumn headerText="name" dataField="@username" width="150"/&gt;
        &lt;DataGridColumn headerText="Nahcname" dataField="@secondname" width="150"/&gt;
        &lt;DataGridColumn headerText="alter" dataField="@age" width="40"/&gt;
    &lt;/columns&gt;
&lt;/DataGrid&gt;
&lt;? ... ?&gt;
</code></pre>

<p>It is working fine.</p>

<p>But I try to create the columns dynamic with PHP.</p>

<pre><code>&lt;generic&gt;
&lt;template target="gridbox"&gt;
    &lt;VBox id="dynamic" height="100%"&gt;
        &lt;!-- DataGrid --&gt;
        &lt;DataGrid id="DataGrid1" width="100%" &gt;
            &lt;columns&gt;
                &lt;?php
                    $columns = array( //Spalte =&gt; (Breite, Datenfeld)
                        "name" =&gt; array(150,"@username"),
                        "Nahcname" =&gt; array(150,"@secondname"),
                        "alter"=&gt; array(40,"@age")
                    );
                    foreach ($columns as $key =&gt; $value) { ?&gt; 
                        &lt;DataGridColumn headerText="&lt;? echo $key; ?&gt;" dataField="&lt;? echo $value[0]; ?&gt;" width="&lt;? echo $value[0];?&gt;"/&gt;
                    &lt;?php } ?&gt; 
            &lt;/columns&gt;
        &lt;/DataGrid&gt;
        &lt;Binding source="templatedata.data1.item" destination="DataGrid1.dataProvider" /&gt;
    &lt;/VBox&gt;
&lt;/template&gt;
&lt;templatedata&gt;
    &lt;data1&gt;
        &lt;!-- Daten --&gt;
        &lt;item username="User1" secondname="Nachname1" age="22"/&gt;
        &lt;item username="User2" secondname="Nachname2" age="25"/&gt;
        &lt;item username="User3" secondname="Nachname3" age="27"/&gt;
        &lt;item username="User4" secondname="Nachname4" age="32"/&gt;
    &lt;/data1&gt;
&lt;/templatedata&gt;
</code></pre>

<p></p>

<p>The DataGrid is displayed correctly, but without data? any idea why?</p>
