单击编辑按钮时,我试图使{ "bSortable": false, "fnRender": function(oObj){return "<a href='main.php?do=labour&action=edit&sid=" + oObj.aData[12] + "'>Edit</a>"; } }弹出。

这是我的GUI

这是我的代码:

    <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>

帮助我的代码从MySQL数据库动态显示jQuery弹出窗口。将为所有行显示一个弹出窗口,但不会显示相同的ID,即未将正确的ID传递给弹出窗口。谁能建议我。

最佳答案

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

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

关于php - Ajax行可编辑数据表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15218363/

10-09 21:11