fastadmin列表中字段換行顯示


PHP:
foreach ($list as $key=>$row) {
    $json = json_decode($row['product_ids'], true);

    $str = '';
    foreach ($json as $key2=>$value) {
        $name = \app\admin\model\product\ProductList::where(array('id'=>$value['id']))->column('productname')[0];
        $price = \app\admin\model\product\ProductList::where(array('id'=>$value['id']))->column('price')[0];

        $str .= '商品名稱:'.$name.',';
        $str .= '購買數量:'.$value['num'].'冊'.',';
        $str .= '商品單價:'.$price.',';
    }

    $str = mb_substr($str, 0, -1);


    $list[$key]['product_ids'] = $str;
}

  



JS:
{field: 'product_ids', title: __('Product_ids'), operate: 'LIKE',formatter: function (value){
        var arr = value.split(',');
        var html = '';
        $.each(arr,function(index,values){
            html += values+'<br/>';
        });
        return html;

    }},

  

 

單一字段自動換行:

{field: 'admin_id', title: __('負責人'), operate: 'LIKE',cellStyle: {css: {"max-width": "300px","white-space":"pre-line","word-wrap":"break-word","word-break":"break-all"}}},


cellStyle: {css: {"max-width": "300px","white-space":"pre-line","word-wrap":"break-word","word-break":"break-all"}}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM