Sohil Shingala
Sohil Shingala

Reputation: 204

jquery-uniform radio button not working yajra-laravel-datatable package (laravel 5.6)

I use yajra-laravel-datatable (laravel 5.6).

I have put jquery-uniform radio button in datatable but that is not working.

I use $.uniform.update() but it is not working.

$(".styled_color_checkbox").uniform({
    radioClass: 'choice',
    wrapperClass: 'border-indigo-600 text-indigo-800'
});

Blade file code

var oTable = $('.finance_payment_datatable').DataTable({
            processing: false,
            serverSide: true,
            ajax: {
                url: '{!! route('admin.finance.invoice.datatable') !!}',
                data: function (d) {
                    var customer_id = $(".customer_select option:selected").val();
                    if (typeof customer_id == 'undefined'){
                        customer_id = '0';
                    }

                    if (customer_id !== '0') {
                        d.customer_id = customer_id;
                    }
                }
            },
            columns: [
                {data: 'maincheck', sortable: false, orderable: false, searchable: false},
                {data: 'invoice_number', name: 'invoice_number', sortable: true},
                {data: 'created_at', name: 'created_at', sortable: true},
                {data: 'outstanding_price', name: 'outstanding_price', sortable: true},
            ],
            order: [[2, 'desc']],
            "pagingType": "full_numbers",
            "language": {
                "emptyTable": "No invoice to display",
                "search": '<span>Filter:</span> _INPUT_',
                "lengthMenu": '<span>Show:</span> _MENU_',

            },
            autoWidth: false,
            'fnDrawCallback': function( oSettings ) {
                $.uniform.update();

            }
        });

Controller file code

public function invoiceDatatable(Request $request) {
        $raw = Invoice::with('user')->select('invoices.*');
        if ($request->has('customer_id')) {
            $raw->where('invoices.user_id', $request->get('customer_id'));
        }

        $raw->where('invoices.outstanding_price', '>=', '1');

        $datatable = app('datatables')->of($raw)

        ->addColumn('maincheck', function ($raw) {
            return '<label><input type="radio" name="invoice" class="styled_color_checkbox outstanding_price" data-amount="'.$raw->outstanding_price.'" value="'.$raw->id.'"></label>';

        })
        ->editColumn('created_at', function ($raw) {
            return date('Y/m/d', strtotime($raw->created_at));
        })
        ->editColumn('outstanding_price', function ($raw) {
            return '$'.$raw->outstanding_price;
        });

        return $datatable->make(true);

    }

Upvotes: 2

Views: 218

Answers (0)

Related Questions