简体   繁体   中英

ajax row editable datatable

I am trying to make { "bSortable": false, "fnRender": function(oObj){return "<a href='main.php?do=labour&action=edit&sid=" + oObj.aData[12] + "'>Edit</a>"; } } { "bSortable": false, "fnRender": function(oObj){return "<a href='main.php?do=labour&action=edit&sid=" + oObj.aData[12] + "'>Edit</a>"; } } to popup when I click edit button.

Here is my gui

GUI

Here is my code:

    <script type="text/javascript" charset="utf-8">
        var oTable;

        /* Formating function for row details */
        function fnFormatDetails ( nTr )
        {
            var aData = oTable.fnGetData( nTr );
            var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
            sOut += '<tr><td>Name:</td><td style="color:blue;">'+aData[3]+' '+aData[4]+' '+aData[5]+'</td></tr>';
            sOut += '<tr><td>Tag ID:</td><td style="color:blue;">'+aData[1]+'</td></tr>';
            sOut += '<tr><td>ID #:</td><td style="color:blue;">'+aData[2]+'</td></tr>';
            sOut += '<tr><td>Course:</td><td style="color:blue;">'+aData[9]+'</td></tr>';
            sOut += '<tr><td>Department:</td><td style="color:blue;">'+aData[7]+'</td></tr>';
            sOut += '<tr><td>Contact:</td><td style="color:blue;">'+aData[8]+'</td></tr>';
            sOut += '<tr><td>Address:</td><td style="color:blue;">'+aData[9]+'</td></tr>';
            sOut += '<tr><td>Last Modified:</td><td style="color:blue;">'+aData[10]+'</td></tr>';
            sOut += '</table>';

            return sOut;
        }
        $(document).ready(function() {
            oTable = $('#example').dataTable( {
                "bProcessing": true,
                "bServerSide": true,
                "sAjaxSource": "scripts/server_processing.php",
                "aoColumns": [
                    { "sClass": "", "bSortable": false },
                    null,
                    null,
                    null,
                    { "sClass": "" },
                    { "sClass": "" },
                    { "bSortable": false, "fnRender":  function(oObj){return "<a href='main.php?do=labour&action=edit&sid=" + oObj.aData[12] + "'>Edit</a>"; } //heres is my problem }

                ],
                "aaSorting": [[1, 'asc']]
            } );

            $('#example tbody td img').live( 'click', function () {
                var nTr = $(this).parents('tr')[0];
                if ( oTable.fnIsOpen(nTr) )
                {
                    /* This row is already open - close it */
                    this.src = "examples_support/details_open.png";
                    oTable.fnClose( nTr );
                }
                else
                {
                    /* Open this row */
                    this.src = "examples_support/details_close.png";
                    oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
                }

            } );

        } );

    </script>

Help my code for displaying jQuery popup dynamically from MySQL database. A popup is displaying for all the rows but not displaying with a same id ie, a correct id wasn't passing to a popup window. Can anyone suggest me.

  { "bSortable": false, "fnRender":  function(oObj){return "<a href='main.php?do=labour&action=edit&sid=" + oObj.aData[12] + "'>Edit</a>"; } 

不应该是oObj.aData [2]而不是oObj.aData [12]吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM