javascript - Get cell data using handsontable - Stack Overflow

I'm looking for insert data in my postgre database from a handsontable data grid. So, I created my

I'm looking for insert data in my postgre database from a handsontable data grid. So, I created my grid and it works but now, I don't know how to use methods like "getData" or "getDataAtCell" to get what the user will insert.

Here is the code :

<div id="example" class="excel"></div>
    <script>

    var data = [
                ["LastName", "FirstName", "Age", "Height"],
                ["", "","" ,""  ]

              ];

              var container = document.getElementById('example');
              var hot = new Handsontable(container, {
                data: data,
                minSpareRows: 1,
                rowHeaders: true,
                colHeaders: false,
                contextMenu: true
              });   
    </script>


    <!--  <a href="#" id="valider">Submit</a>-->
    <button type="button" class="btn btn-default" id="submit_button">Submit</button>

<script>
    $(document).ready(function(){
        $('#submit_button').click(function(){
            //alert ("test");

            //getDataAtCell(1,1);

            <?php 
                //$conn_string = "host=localhost port=5432 dbname=ita2015 user=postgres password='1234'";
                //$dbconn = pg_connect($conn_string);

                //$sql = "INSERT INTO test_perso.etudiant(id_etudiant, nom_etudiant) 
                //        VALUES('5', ".data[1][0].");";
                //$res = pg_query($sql) or die("Pb avec la requete: $sql");


                //echo data[0][0];
            ?>
            var temp;

            temp = $("#example").handsontable('getCell', 0, 0);
            alert(temp);
        });

    });

</script>

I'm looking for insert data in my postgre database from a handsontable data grid. So, I created my grid and it works but now, I don't know how to use methods like "getData" or "getDataAtCell" to get what the user will insert.

Here is the code :

<div id="example" class="excel"></div>
    <script>

    var data = [
                ["LastName", "FirstName", "Age", "Height"],
                ["", "","" ,""  ]

              ];

              var container = document.getElementById('example');
              var hot = new Handsontable(container, {
                data: data,
                minSpareRows: 1,
                rowHeaders: true,
                colHeaders: false,
                contextMenu: true
              });   
    </script>


    <!--  <a href="#" id="valider">Submit</a>-->
    <button type="button" class="btn btn-default" id="submit_button">Submit</button>

<script>
    $(document).ready(function(){
        $('#submit_button').click(function(){
            //alert ("test");

            //getDataAtCell(1,1);

            <?php 
                //$conn_string = "host=localhost port=5432 dbname=ita2015 user=postgres password='1234'";
                //$dbconn = pg_connect($conn_string);

                //$sql = "INSERT INTO test_perso.etudiant(id_etudiant, nom_etudiant) 
                //        VALUES('5', ".data[1][0].");";
                //$res = pg_query($sql) or die("Pb avec la requete: $sql");


                //echo data[0][0];
            ?>
            var temp;

            temp = $("#example").handsontable('getCell', 0, 0);
            alert(temp);
        });

    });

</script>
Share Improve this question asked Jun 18, 2015 at 9:25 ErlaunisErlaunis 1,4516 gold badges33 silver badges50 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

I would probably look at the documentation to figure out how to use those two methods. Essentially, those methods are available to you using the hot instance so something like hot.getDataAtCell(0,0) will return to you the data at position 0,0. You could also use hot.getData() which returns the entire data array.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743753112a4501266.html

相关推荐

  • javascript - Get cell data using handsontable - Stack Overflow

    I'm looking for insert data in my postgre database from a handsontable data grid. So, I created my

    12天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信