jeudi 17 mai 2018

In yajra datatable, After search, group concat all values are remove except exact match

I have used the yajra datatable to search columns.Before search datatable show all tags as you can see in below screenshot.

But After the search of tag in search box. only match exact word and remove the other tags.It should match exact word with all tags. enter image description here

I want my final result would be below. enter image description here

In my laravel controller,

This is select query where I am using group concat for multiple tags. I have only pasted select query.

$i_items = $items->select('items.description', DB::raw("GROUP_CONCAT(item_tags.tag) as tags");
        return Datatables::of($i_items)->make(true);

My view.blade.php to render datatable as below.

$('#table').DataTable({
        processing: true,
        serverSide: true,
        ajax: '',
        columns: [

            {
                data: 'description',
                render: function ( data, type, row ) {
                        return (row['account_id'] != 1) ? data : '<div class="td_list">'+data+'</div><div class="td_edit hide_td"><input class="item_description form-control" name="item_description" type="text"  placeholder="Description" style="margin:0px; width: 80%;" value="'+data+'"></input></div>';
                },
                className: 'td_description',
                defaultContent: "<i>Not set</i>",

            },
            {

                data: 'tags', name: 'item_tags.tag',
                render: function ( data, type, row ) {
                        if(data !== null && data !== '') {
                            var tags = data.split(",");
                        } else
                        {
                            return;
                        }


                        var final_tags = "";
                        var final_option = "";
                        tags.forEach(function(tag) {
                            final_tags += '<label class="badge badge-default" style="padding: 5px; font-size: 12px;">' + tag + '</label> ';
                            if(tag)
                            {
                                final_option += '<option value="'+tag+'" selected>'+tag+'</option>';
                            }
                        });
                        return (row['account_id'] != 1) ? final_tags : '<div class="td_list">'+final_tags+'</div><div class="td_edit hide_td"><select name="item_tags[]" class="item_tags" multiple style="width: 80%;">'+ final_option +'</select></div>';

                },
                className: 'td_tag',
                defaultContent: "<i>Not set</i>",


            },

        ],

    });

Please help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire