2

Soo.. i got an example of EditableGrid (http://www.editablegrid.net/) a pretty cool grid that lets me load data from mysql table to a html grid with sorting, inline editing + mysql database updates. I added filtering functionality from another example but am struggling with adding delete row and add row functionality.

I found an example of how to delete by adding a new column and i could call an update function from there.. but i'm struggling with syntax and where to place it .. javascript has me bretty boggled so far.. http://www.editablegrid.net/editablegrid/examples/simple/index.html

The output is loaded on to a div in a simple html file and works very well.. nice and fast and updated great. I just want to add 'new' and 'delete' functions to the table.

Any assistance appreciated.

function DatabaseGrid()
{
        this.editableGrid = new EditableGrid("plan_customerid", {
        enableSort: true,
        editmode: "absolute",
        editorzoneid: "edition",
        tableLoaded: function() {
          datagrid.initializeGrid(this);
        },
        modelChanged: function(rowIndex, columnIndex, oldValue, newValue, row) {
            updateCellValue(this, rowIndex, columnIndex, oldValue, newValue, row); },
        });
        this.fetchGrid();
}

DatabaseGrid.prototype.fetchGrid = function()  {
        // call a PHP script to get the data
        this.editableGrid.loadXML("loaddata.php");
};

DatabaseGrid.prototype.initializeGrid = function(grid) {
        grid.renderGrid("tablecontent", "testgrid", "tableid");
        tableRendered = function() { this.updatePaginator(); };
        _$('filter').onkeyup = function() { grid.filter(_$('filter').value); };
 };

the output from loaddata.php is such:

<table>
<metadata>
<column name="customer_id" label="UID" datatype="string" editable="true"></column>
<column name="customer" label="Customer" datatype="string" editable="true"></column>
<column name="lastchange_by" label="Editor" datatype="string" editable="true"></column>
<column name="ts" label="Timestamp" datatype="date" editable="true"></column>
</metadata>
<data>
<row id="1">
<column name="customer_id">
<![CDATA[ 5000 ]]>
</column>
<column name="customer">
<![CDATA[ Foo ]]>
</column>
<column name="lastchange_by">
<![CDATA[ Bar ]]>
</column>
<column name="ts">
<![CDATA[ 2013-10-17 00:00:00 ]]>
</column>
</row>
</data>
</table>
mpromonet
  • 11,326
  • 43
  • 62
  • 91
CptAhab
  • 23
  • 2
  • 6

0 Answers0