Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery dataTable Editable Cell

I give up as I have been messing around with this for the past 4 hours and I am just not getting anywhere. When using the jquery datatable found here. http://datatables.net/examples/api/editable.html (seems like a very popular plug in) I can get pretty much everything I want to work except the editable cell part. I have my file in this order

<script src="JS/jquery.js"></script>
<script src="JS/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="JS/jquery.jeditable.js"></script>
<script src="JS/jquery.validate.js"></script>
<script src="JS/ColReorder.min.js"></script>
<link href="JS/css/jquery.dataTables.css" rel="stylesheet" />

and then I have this script to get the table initialized.

function formattable(thistable) {
        //alert(thistable + " from format table")
       // $(document).ready(function () {
            //  ADPControlProcessor_Table1
        //$("#ADPControlProcessor_GridView1").dataTable();

        var oTable = $("#ADPControlProcessor_GridView1").dataTable({
                //"bFilter": true,
                "sScrollY": "200px",
                "bPaginate": false,
                "bAutoWidth": false,
                "sDom": 'Rlfrtip'



            //});
            //alert("running");
       });

        //var oTable = $('#example').dataTable();

        /* Apply the jEditable handlers to the table */
        $('td', oTable.fnGetNodes()).editable('../examples_support/editable_ajax.php', {
            "callback": function (sValue, y) {
                var aPos = oTable.fnGetPosition(this);
                oTable.fnUpdate(sValue, aPos[0], aPos[1]);
            },
            "submitdata": function (value, settings) {
                return {
                    "row_id": this.parentNode.getAttribute('id'),
                    "column": oTable.fnGetPosition(this)[2]
                };
            },
            "height": "14px"
        });

I dont know what elese to try. can anyone point me in the right direction.

like image 390
Miguel Avatar asked Nov 23 '25 08:11

Miguel


1 Answers

Instead of paying for the editable plugin I built my own which you're free to use. The repo is here: DataTables CellEdit Plugin

The basic initialization is quick and easy:

oTable.MakeCellsEditable({
    "onUpdate": myCallbackFunction
});

myCallbackFunction = function (updatedCell, updatedRow) {
    console.log("The new value for the cell is: " + updatedCell.data());
}
like image 100
Elliott Avatar answered Nov 25 '25 21:11

Elliott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!