Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.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
使用Yajra对Laravel中的列重新排序Datatable_Laravel_Datatable - Fatal编程技术网

使用Yajra对Laravel中的列重新排序Datatable

使用Yajra对Laravel中的列重新排序Datatable,laravel,datatable,Laravel,Datatable,我正在使用Yajra处理Laravel数据表。 我试图通过传递数组值来填充表 我的表格结构如下: <table id="daily_datatable" class="table table-striped table-bordered"> <thead> <tr> <th rowspan="2">Region</th> <th rowspan="2">Country</th&g

我正在使用Yajra处理Laravel数据表。 我试图通过传递数组值来填充表

我的表格结构如下:

<table id="daily_datatable" class="table table-striped table-bordered">
<thead>
    <tr>
        <th rowspan="2">Region</th>
        <th rowspan="2">Country</th>
        <th rowspan="2">No of accounts</th>
        <th rowspan="2">Bank Account Pending</th>
    </tr>
</thead>
$('#daily_datatable').DataTable({
    processing:true,
    serverSide:true,
    rowReorder: true,
    ajax:
    {
        url:"{!! URL::to('dailyreportDatatable') !!}"
    },
    dom: 'Bfrtip',
    buttons: ['pageLength','csv','excel', 'pdf'],
    columns:[
        {data:'region',name:'region'},
        {data:'country',name:'country'},
        {data:'noofaccounts',name:'noofaccounts'},
        {data:'accountpending',name:'accountpending'},  
    ]
});
public function dailydatatable(){
    $final = new Collection;
    $from_date = date("Y-m-d");
    $to_date = date("Y-m-d");
    $pastfrom_date  = date("Y-m-d", strtotime("-2 days"));
    $pastto_date    = date("Y-m-d", strtotime("-2 days"));
    $country = AccMaster::select('ms_region','ms_country','ms_bacc_num')->groupby('ms_country')->get()->toArray();
    foreach($country as $countryCode){
        $pending = AccMaster::select('ms_bacc_num')->where('ms_country',$countryCode['ms_country'])->get()->toArray();
        $bankacc = $this->getBankAcc($pending);

        $final->push([
            'region'=>$countryCode['ms_region'],
            'country'=>$countryCode['ms_country'],
            'noofaccounts'=>$this->getAccounts($countryCode['ms_country']),
            'accountpending'=>$this->getAccPending($countryCode['ms_country'],$bankacc),
        ]);
    }
    return Datatables::of($final)->make(true);
}
我的控制器方法如下:

<table id="daily_datatable" class="table table-striped table-bordered">
<thead>
    <tr>
        <th rowspan="2">Region</th>
        <th rowspan="2">Country</th>
        <th rowspan="2">No of accounts</th>
        <th rowspan="2">Bank Account Pending</th>
    </tr>
</thead>
$('#daily_datatable').DataTable({
    processing:true,
    serverSide:true,
    rowReorder: true,
    ajax:
    {
        url:"{!! URL::to('dailyreportDatatable') !!}"
    },
    dom: 'Bfrtip',
    buttons: ['pageLength','csv','excel', 'pdf'],
    columns:[
        {data:'region',name:'region'},
        {data:'country',name:'country'},
        {data:'noofaccounts',name:'noofaccounts'},
        {data:'accountpending',name:'accountpending'},  
    ]
});
public function dailydatatable(){
    $final = new Collection;
    $from_date = date("Y-m-d");
    $to_date = date("Y-m-d");
    $pastfrom_date  = date("Y-m-d", strtotime("-2 days"));
    $pastto_date    = date("Y-m-d", strtotime("-2 days"));
    $country = AccMaster::select('ms_region','ms_country','ms_bacc_num')->groupby('ms_country')->get()->toArray();
    foreach($country as $countryCode){
        $pending = AccMaster::select('ms_bacc_num')->where('ms_country',$countryCode['ms_country'])->get()->toArray();
        $bankacc = $this->getBankAcc($pending);

        $final->push([
            'region'=>$countryCode['ms_region'],
            'country'=>$countryCode['ms_country'],
            'noofaccounts'=>$this->getAccounts($countryCode['ms_country']),
            'accountpending'=>$this->getAccPending($countryCode['ms_country'],$bankacc),
        ]);
    }
    return Datatables::of($final)->make(true);
}
我无法绘制数据表。我得到了错误

jquery.dataTables.min.js:31未捕获类型错误:无法设置属性 未定义的“0”


您需要重写html表,因为您忘记了end
tr
标记

<table id="daily_datatable" class="table table-striped table-bordered">
<thead>
    <tr>
        <th rowspan="2">Region</th>
        <th rowspan="2">Country</th>
        <th rowspan="2">No of accounts</th>
        <th rowspan="2">Bank Account Pending</th>
    </tr> 
</thead>

区域
国家
帐户数目
银行帐户待定

dd($final)是什么意思;返回之前的输出?$final=结果为Nothing我获取结果数组检查控制台中是否返回数据?