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

multiple multiselectaction with multiple datatables on the same page#626

Open
darektw wants to merge 2 commits intostwe:masterfrom
darektw:master
Open

multiple multiselectaction with multiple datatables on the same page#626
darektw wants to merge 2 commits intostwe:masterfrom
darektw:master

Conversation

@darektw
Copy link
Copy Markdown
Contributor

@darektw darektw commented Jun 4, 2017

First of all thakns for Your Great job, it's awesome bundle.
I had a problem with multiple datatables generated for each category, i needed display them on one page. It works but without multiselect actions.

In my case there is one original databele and multiple tabs with dynamic datatables created from original datatable. I pass an extra parameter in bulidDatatable method to suffix datatablename.

The code below explain how it works.
The code in pull request is the hotfix to resolve the problem.
The question is how do it better :)

// in controler
$datatable->buildDatatable(['category_slug' => $query_cslug]);

// in datatable
$this->dtName = 'media_datatable_' . $options['category_slug'];

/**
 * {@inheritdoc}
 */
public function getName()
{
   return $this->dtName;
}

each datatable should have different name

{% if sg_datatables_view.columnBuilder.uniqueColumn('multiselect') is not null %}
{{ sg_datatables_render_multiselect_actions( sg_datatables_view.columnBuilder.uniqueColumn('multiselect'), sg_datatables_view.ajax.pipeline) }}
{{ sg_datatables_render_multiselect_actions( sg_datatables_view.columnBuilder.uniqueColumn('multiselect'), sg_datatables_view.ajax.pipeline, sg_datatables_view.name) }}
Copy link
Copy Markdown
Contributor Author

@darektw darektw Jun 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this place sg_datatables_view.name has correct suffixed datatablename

$actions = $this->accessor->getValue($multiselectColumn, 'actions');
$domId = $this->accessor->getValue($multiselectColumn, 'renderActionsToId');
$datatableName = $this->accessor->getValue($multiselectColumn, 'datatableName');
$datatableName = $datatableName ?: $this->accessor->getValue($multiselectColumn, 'datatableName');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->accessor->getValue($multiselectColumn, 'datatableName'); return always dtatablename from contructor, without suffix, so i need to pass an extra parameter

@darektw darektw changed the title multiselectaction with multiple datatables on the same page multiple multiselectaction with multiple datatables on the same page Jun 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant