Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by hairtha on Sep 18, 2008 05:04
open dhtmlx forum
how to add grid features if i load data from html table

Hi,

I initialized grid with html table data as follows by giving the class name:

<table class="dhtmlxGrid"  style="width:400px" lightnavigation="true">
        <!--- First row treatted as grid header  --->
        <tr>
            <!--- First column can't be edited  --->
            <td type="ro">Column 1</td>
            <td>Column 2</td>
        </tr>
        <!--- All other rows - Grid body --->
        <tr>
            <td>value 11</td>
            <td>value 12</td>
        </tr>
        <tr>
            <td>value 21</td>
            <td>value 22</td>
        </tr>

    </table>
 
 So now i want to add features such as filtering ,searching, adding rows, deleting rows.
if we have a grid object we can use api functions to add these features but now i don't have grid object. so how can i achieve this

Pls can any one help me.

thanks
haritha
Answer posted by Support on Sep 19, 2008 05:50
This table can also have following attributes:
- name: sets the name of the grid object
- onbeforeinit: sets fucntion which will be called before intialization;
- oninit: sets function called after initialization.

So  you can do the following:

<table name="mygrid" onbeforeinit="doBeforeInit()"  oninit="doAfterInit()" class="dhtmlxGrid" style="width:400px" lightnavigation="true">
<tr>
<td type="ro">Column 1</td>
<td>Column 2</td>
</tr>
<!--- All other rows - Grid body --->
<tr id="1">
<td>value 11</td>
<td>value 12</td>
</tr>
<tr id="2">
<td>value 21</td>
<td>value 22</td>
</tr>
</table>

<script>
function doBeforeInit(){
mygrid.attachHeader("....");
}
function doAfterInit(){
mygrid.deleteRow('2')
}
</script>