Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

So, what with column filters ? #347

Open
e1sep0 opened this issue Jun 9, 2024 · 3 comments · May be fixed by #348
Open

So, what with column filters ? #347

e1sep0 opened this issue Jun 9, 2024 · 3 comments · May be fixed by #348

Comments

@e1sep0
Copy link

e1sep0 commented Jun 9, 2024

Hi, are you planning to fix column filters? They're not displayed (
Neither Choice filter, nor Text filter:

$statusFilter = new ChoiceFilter();
        $statusFilter->set([
            'choices' => ['foo' => 'bar', 'bar' => 'baz']
        ]);
        $textFilter = new TextFilter();

        $table = $dataTableFactory->create()
            ->add('id', TextColumn::class, ['label' => 'Id'])
            ->add('status', TextColumn::class, ['field' => 'e.status','searchable' => true, 'filter' => $statusFilter])
            ->add('name', TextColumn::class, [ 'field' => 'e.name', 'filter' => $textFilter])
            ->createAdapter(ORMAdapter::class, [
                'entity' => Entity::class,
                'hydrate' => AbstractQuery::HYDRATE_ARRAY,
                'query' => function (QueryBuilder $builder) use ($scheduleIds): void {
                    $builder
                        ->select('e')
                        ->from(Entity::class, 'e')
                    ;
                },
            ])
            ->handleRequest($request);

datatables.yaml:

# Latest documentation available at https://omines.github.io/datatables-bundle/#configuration
datatables:
    language_from_cdn: false
    # Set options, as documented at https://datatables.net/reference/option/
    options:
        lengthMenu : [10, 25, 50, 100, 250, 500, 1000, 2500]
        pageLength: 10
        dom: "<'row' <'col-sm-12' ftr>><'row' <'col-sm-6'l><'col-sm-6 text-right'pi>>"
        searching: true

    template_parameters:
        # Example classes to integrate nicely with Bootstrap 3.x
        className: 'table table-bordered table-hover data-table report-table'
        columnFilter: 'both'

    # You can for example override this to "tables" to keep the translation domains separated nicely
    translation_domain: 'messages'

table.html.twig:

$(function () {
            $('#table').initDataTables({{ datatable_settings(datatable) }},
                {
                    searching: true,
                    dom: 'Bfltip',
                });
        });
@curry684
Copy link
Member

Column filters are essentially "unsupported, use at own risk". People are using them and happy with them but I have no clue how they work as we don't use it ourselves. PRs to improve them welcome.

@rostyslav-a-smartgamma
Copy link

Hope this feature will work soon in further updates, I need a multiple choice filter/search... As I see there is no way how to do this with column search.

@kathibeepboop
Copy link

There is a open pr for this #348
Alternativly you could use my fork (which is poorly maintainted) and use the column filters #336 (comment)

Keep in mind that my fork will get some other changes too, like case insensitive global search and stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants