protonemedia / inertiajs-tables-laravel-query-builder

Inertia.js Tables for Laravel Query Builder
https://protone.media/en/blog/introducing-inertiajs-tables-a-datatables-like-package-for-laravel-query-builder
MIT License
438 stars 123 forks source link

Checkbox state looks weird enabled/disabled (visible/hidden) #52

Closed renepardon closed 2 years ago

renepardon commented 2 years ago

image

So the first one is disabled but why is the switch for the others also on the left?

And as mentioned here: https://github.com/protonemedia/inertiajs-tables-laravel-query-builder/issues/14#issuecomment-984563253 If the id-column is set to enabled=false (which I think should be "hidden=true" or "visible=false") I'm not able to display the id column. All other columns can be hidden and displayed again except for the ones hidden (disabled) by default through the new third parameter.

FranzaLeny commented 2 years ago

I disable same line in node_modules\@protonemedia\inertiajs-tables-laravel-query-builder\js\InteractsWithQueryBuilder.vue

getColumnsForQuery(columns) { let enabledColumns = filter(columns, (column) => { return column.enabled; }); // if (enabledColumns.length === Object.keys(columns || {}).length) { // return []; // } return map(enabledColumns, (column) => { return column.key; }); },

and in controller i added app\Http\Controllers\XxxxxxxController.php

$fields = request('columns') ?? []; $table->addColumn('golongan', 'Golongan', in_array('golongan', $fields) ? true : false);

this not best pratctice but for now i used this for waiting update from this module...

renepardon commented 2 years ago

@FranzaLeny it's never a good idea to directly change library code. Hope there will be an update soon or we need to make a pull request :)

patrocle commented 2 years ago

Hi,

I've done the same. I can't have a column disable by default other way. It's simply doesn't work when I want to show the hidden default column, there is an automatic refresh that hide the column 500ms after I click the show button.

So I wait for the fix, during this time I use the @FranzaLeny solution.

$fields = request('columns') ?? [];
$table->addColumn('golongan', 'Golongan', in_array('golongan', $fields) ? true : false);
getColumnsForQuery(columns) {
            let enabledColumns = filter(columns, (column) => {
                return column.enabled;
            });

            //if (enabledColumns.length === Object.keys(columns || {}).length) {
            //    return [];
            //}

            return map(enabledColumns, (column) => {
                return column.key;
            });
        },
pascalbaljet commented 2 years ago

Fixed in v2