webismymind / editablegrid

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.
http://www.editablegrid.net
Other
795 stars 272 forks source link

Multiple editablegrid table in the same page #114

Closed capaaway closed 8 years ago

capaaway commented 8 years ago

Hi , coul someone help me to insert more than one editablegrid table in the same html page? The pourpose is to have 3 editable of the same table , filtered in 3 different ways . Thanks! Fabio

webMac commented 8 years ago

Hi, this is how it works for me:

  1. Just define one
    Tag per editable grid you want to use
  2. Init and handle each editable grid with it's own JavaScript code reffering your html div id

somehow like that:

<!DOCTYPE html>
<html>
    <head>
        <title>Two Grids</title>
        <script src="editablegrid.js"></script>
        <script type="text/javascript">

            var editableGrid1 = new window.EditableGrid("editableGrid1", {
                editmode: "static"
                // ...
            });

            editableGrid1.tableLoaded = function(){ 
                this.renderGrid("grid1", "grid");
                // ... 
            };

            editableGrid1.modelChanged = function (rowIndex, columnIndex, oldValue, newValue, row) {
                editableGrid1.saveChanges(row, rowIndex);
            };

            var editableGrid2 = new window.EditableGrid("editableGrid2", {
                editmode: "static"
                // ...
            });

            editableGrid2.tableLoaded = function(){ 
                this.renderGrid("grid2", "grid");
                // ... 
            };

            editableGrid2.modelChanged = function (rowIndex, columnIndex, oldValue, newValue, row) {
                editableGrid2 .saveChanges(row, rowIndex);
            };

        </script>
    </head>
    <body>
        <h1>Grid 1</h1>
        <div id="grid1"></div>
        <h1>Grid 2</h1>
        <div id="grid2></div>
    </body>
</html>
capaaway commented 8 years ago

Thanks! Fabio