Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 要获取我选择的行的主键datatables吗_Php_Codeigniter_Datatables - Fatal编程技术网

Php 要获取我选择的行的主键datatables吗

Php 要获取我选择的行的主键datatables吗,php,codeigniter,datatables,Php,Codeigniter,Datatables,我在一个数据库中有一个表,它输出这个JSON: {"sEcho":1, "iTotalRecords":7, "iTotalDisplayRecords":7, "aaData":[ {"FormID":"6", "FormName":"Configuration", "FormPath":"#","FormCIPath":"#"}, {"FormID":"1", "FormName":"Dashboard",

我在一个数据库中有一个表,它输出这个JSON:

{"sEcho":1,
"iTotalRecords":7,
"iTotalDisplayRecords":7,
"aaData":[
    {"FormID":"6",
         "FormName":"Configuration",
          "FormPath":"#","FormCIPath":"#"}, 
    {"FormID":"1",
          "FormName":"Dashboard",
          "FormPath":"#",
           "FormCIPath":"admin\/dashboard\/System"}],
"sColumns":"FormName,FormPath,FormCIPath"}
但我并没有给datatables中的任何列指定FormID,因为我不想向公众显示数据库的FormID

但是我怎样才能得到FormID呢

下面是Javascript:

<script>
    $(document).ready(function() {
        var oTable = $('#ManageForms').dataTable({

            "bServerSide":true,
            "bProcessing":true,
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "bFilter":true,
            "sServerMethod": "POST",
            "sAjaxSource": "{{base_url()}}admin/configurations/listForms_DT/",
            "iDisplayLength": 2,
            "aLengthMenu": [[2, 25, 50, -1], [2, 25, 50, "All"]],
            "sEcho": 1,
            "columns":[
                {data:"FormName"},
                {data:"FormPath"},
                {data:"FormCIPath"},
                { "data": null,
                    "defaultContent": "<a href='#editBtnModal' class='editBtnFunc' ><i style='color: #666666' class='fa fa-pencil fa-fw fa-2x'></i></a><a href='#' id='deleteBtn'><i style='color: #ff0000' class='fa fa-times fa-fw fa-2x'></i></a>",
                    "targets": -1
                }
            ],
            'fnServerData'   : function(sSource, aoData, fnCallback){
                $.ajax ({
                    'dataType': 'json',
                    'type'    : 'POST',
                    'url'     : sSource,
                    'data'    : aoData,
                    'success' : fnCallback
                }); //end of ajax
            }
        });

        //Edit Button on Modal Window
        $('#ManageForms').on('click', '.editBtnFunc', function(e){
            e.preventDefault();
            //var aPos = oTable.fnGetPosition( this );
            //var aData = oTable.fnGetData( aPos[0] );
            console.log(oTable);
        });
        //Edit Button
    } );


</script>

$(文档).ready(函数(){
变量oTable=$('#ManageForms')。数据表({
“bServerSide”:正确,
“bProcessing”:正确,
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”,
“bFilter”:没错,
“sServerMethod”:“POST”,
“sAjaxSource”:“{{base_url()}}admin/configurations/listForms_DT/”,
“iDisplayLength”:2,
“阿伦提努”:[[2,25,50,-1],[2,25,50,“全部”],
"sEcho":1,,
“栏目”:[
{数据:“FormName”},
{data:“FormPath”},
{数据:“FormCIPath”},
{“数据”:空,
“defaultContent”:“,
“目标”:-1
}
],
“fnServerData”:函数(sSource、aoData、fnServerData回调){
$.ajax({
“数据类型”:“json”,
'type':'POST',
“url”:sSource,
“数据”:aoData,
“成功”:fn回调
});//ajax的结束
}
});
//模式窗口上的编辑按钮
$('#ManageForms')。on('click','.editBtnFunc',函数(e){
e、 预防默认值();
//var aPos=可旋转的.fGetPosition(此);
//var aData=oTable.fngedata(aPos[0]);
控制台日志(可旋转);
});
//编辑按钮
} );
这是HTML

<div class="row ui-sortable">
    <div class="col-lg-12">
        <div class="box">
            <header>
                <div class="icons">
                    <i class="fa fa-table"></i>
                </div>
                <h5>Manage Forms</h5>
            </header>
            <div class="body" id="collapse4">
                <table id="ManageForms" class="table table-bordered table-condensed table-hover table-striped">
                    <thead>
                        <tr>
                            <th>Form Name</th>
                            <th>Form Path</th>
                            <th>Form CI Path</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
</div>

管理表单
表格名称
形成路径
表单CI路径
行动

要获取fnGetPosition(此),您应该单击表格正文中的TR、TD或TH。您可以找到“.editBtnFunc”标记最近的td或tr,并获取行的位置

   $('#ManageForms').on('click', '.editBtnFunc', function(e){
          var row = $(this).closest('tr');
          var aPos = oTable.fnGetPosition( row );
          var aData = oTable.fnGetData( aPos[0] ); 
    });