Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Url in Select2Filter with parameter #855

Open

Description

@RLNat

Hey!

I have a datatables with places.
What I want is to list in the select2Filter only sections in the room.
How can I pass the id of the room (section.room.id) in the url (manage_section_list).

Thank you.

Here the PlaceDatatable.php :

`/**
* Builds the datatable.
*
* @PARAM array $options
*/
public function buildDatatable(array $options = array())
{
// TODO: Implement buildDatatable() method.
$this->language->set(array(
'cdn_language_by_locale' => true,
));

    $this->ajax->set(array());

    $this->options->set(array(
        'classes' => Style::BOOTSTRAP_3_STYLE . ' table-responsive',
        'individual_filtering' => true,
        'individual_filtering_position' => 'head',
        'order' => array(array(0, 'asc')),
        'order_cells_top' => true,
        'length_menu' => array(15, 25, 50, 100),
        'page_length' => 15,
        'paging_type' => Style::FULL_NUMBERS_PAGINATION
    ));

    $this->features->set(array(
        'auto_width' => true,
        'defer_render' => false,
        'info' => true,
        'length_change' => true,
        'ordering' => true,
        'paging' => true,
        'processing' => true,
        'scroll_x' => false,
        'scroll_y' => '',
        'searching' => true,
        'state_save' => false
    ));

    $this->columnBuilder
        ->add('id', Column::class, array(
            'title' => '',
            'searchable' => false,
            'orderable' => true,
        ))
        ->add('section.name', Column::class, array(
            'title' => 'Section',
            'width' => '100%',
            'filter' => array(Select2Filter::class,
                array(
                    'search_type' => 'eq',
                    'cancel_button' => true,
                    'url' => 'manage_section_list',
                ),
            ),
        ))
        ->add('number', Column::class, array(
            'title' => 'Number',
            'width' => '100%',
        ))
        ->add('section.room.id', Column::class, array(
            'title' => 'Room',
            'width' => '100%',
        ))
    ;
}`

Activity

  1. stephanvierkant commented on Aug 5, 2019

    @stephanvierkant
    Collaborator

    This isn't possible right now, but it really should be.

  2. poulou0 commented on Oct 1, 2020

    @poulou0

    I think its easy, at least in theory!

    If we make a custom twig function to check if the route name exists
    and use it in Resources/views/filter/select2.html.twig line 33
    it will work for both route names and generated paths like:

    ...
    ->add('name', Column::class, array(
        'title' => 'Title',
        'searchable' => true,
        'orderable' => true,
        'filter' => [Select2Filter::class, [
            'url' => $this->router->generate('some_route', ['id' => $options['entity_id']]),
    ...

    Should I fork and try or its so easy that its not worth it?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions