dsiuy42084 2018-05-26 07:31
浏览 44

布尔1和0在yajra laravel-datatables上无法搜索

I have this boolean data of 1 = 'Active' and 0 = 'Inactive'.

I successfully rendered it to the datatable, but the problem if I trying to search 'Active' or 'Inactive' it shows No matching records found.

Is there any solution for this problem?

Here is my datatable js code

columns: [
            { data: 'photo', name: 'photo' },
            { data: 'full_name', name: 'full_name' },
            { data: 'm_lname', name: 'm_lname'},
            { data: 'm_fname', name: 'm_fname'},
            { data: 'm_mname', name: 'm_mname'},
            { data: 'm_gender', name: 'm_gender' },
            { data: 'm_datebaptized', name: 'm_datebaptized' },
            { data: 'm_isactive', name: 'm_isactive',
            render: function ( data, type, full, meta ) {
               return data ? "Active" : "Inactive" ;
            }
        },

            { data: 'action', name: 'action' },

        ],columnDefs: [
            { targets: [2,3,4], visible: false},
            { targets: '_all', visible: true },
            { searchable: true, targets: '_all'},
            { searchable: false, targets: [0,8]},
            { orderData: 2, targets: 1 },
        ],

Thank you.

  • 写回答

1条回答 默认 最新

  • duanfenhui5511 2018-05-26 18:38
    关注

    try to move mapping to

    return datatables()->of(User::all()->map(function ($item) {
        $item->m_isactive = $item->m_isactive ? 'Active' : 'Inactive';
        return $item;
    })->toJson();
    

    and delete

    render: function ( data, type, full, meta ) {
                   return data ? "Active" : "Inactive" ;
                }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致