Soo.. EditableGrid ( http://www.editablegrid.net/ ) の例を入手しました。これは、並べ替え、インライン編集、および mysql データベースの更新を使用して、mysql テーブルから html グリッドにデータをロードできる非常にクールなグリッドです。別の例からフィルタリング機能を追加しましたが、行の削除と行の追加機能の追加に苦労しています。
新しい列を追加して削除する方法の例を見つけたので、そこから更新関数を呼び出すことができました..しかし、構文とそれを配置する場所に苦労しています..javascriptはこれまでのところ私を悩ませています..http :/ /www.editablegrid.net/editablegrid/examples/simple/index.html
出力は単純な html ファイルの div にロードされ、非常にうまく機能します。「新規」および「削除」関数をテーブルに追加したいだけです。
任意の支援をいただければ幸いです。
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); };
};
loaddata.php からの出力は次のようになります。
<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>