N°5335 Disable datatables hyperlinks when rows are selectable

This commit is contained in:
Stephen Abello
2022-07-29 09:59:00 +02:00
parent d60109d3c9
commit 8c7fa53696
5 changed files with 30 additions and 5 deletions

View File

@@ -255,7 +255,7 @@ class UILinksWidgetDirect
$oDiv = UIContentBlockUIBlockFactory::MakeStandard($this->sInputid, ['listContainer']);
$oPage->AddSubBlock($oDiv);
$oDatatable = DataTableUIBlockFactory::MakeForForm($this->sInputid, $aAttribs, $aData);
$oDatatable->SetOptions(['select_mode' => 'custom']);
$oDatatable->SetOptions(['select_mode' => 'custom', 'disable_hyperlinks' => true]);
$oDiv->AddSubBlock($oDatatable);
$sInputName = $sFormPrefix.'attr_'.$this->sAttCode;
$aLabels = array(

View File

@@ -403,7 +403,7 @@ JS
$oBlock->iMaxAddedId = (int) $iMaxAddedId;
$oDataTable = DataTableUIBlockFactory::MakeForForm("{$this->m_sAttCode}{$this->m_sNameSuffix}", $this->m_aTableConfig, $aForm);
$oDataTable->SetOptions(['select_mode' => 'custom']);
$oDataTable->SetOptions(['select_mode' => 'custom', 'disable_hyperlinks' => true]);
$oBlock->AddSubBlock($oDataTable);
$oBlock->AddControls();

View File

@@ -104,10 +104,14 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
}
$(this).closest('.dataTables_wrapper').unblock();
// Disable hyperlinks if necessary
{% if oUIBlock.GetOption("disable_hyperlinks") is not same as false %}
$("#{{ oUIBlock.GetId() }} a").on('click', function (e) {
//disable select action when there is a link
e.stopPropagation();
});
e.preventDefault();
});
{% endif %}
},
{% else %}
drawCallback: function (settings) {
@@ -125,6 +129,13 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
{
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show();
}
// Disable hyperlinks if necessary
{% if oUIBlock.GetOption("disable_hyperlinks") is same as true %}
$("#{{ oUIBlock.GetId() }} a").on('click', function (e) {
e.preventDefault();
});
{% endif %}
},
{% endif %}
rowId: "id",

View File

@@ -37,6 +37,13 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
{
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show();
}
// Disable hyperlinks if necessary
{% if oUIBlock.GetOption("disable_hyperlinks") is same as true or (oUIBlock.GetOption("select_mode") is not empty and oUIBlock.GetOption("disable_hyperlinks") is not same as false) %}
$("#{{ oUIBlock.GetId() }} a").on('click', function (e) {
e.preventDefault();
});
{% endif %}
},
createdRow: function (row, data, dataIndex) {
if (data['@class'] !== undefined)

View File

@@ -73,6 +73,13 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
{
$(this).closest('.dataTables_wrapper').find('.checkAll')[0].checked = true;
}
// Disable hyperlinks if necessary
{% if oUIBlock.GetOption("disable_hyperlinks") is same as true or (oUIBlock.GetOption("select_mode") is not empty and oUIBlock.GetOption("disable_hyperlinks") is not same as false) %}
$("#{{ oUIBlock.GetId() }} a").on('click', function (e) {
e.preventDefault();
});
{% endif %}
},
initComplete: function () {
if (this.api().page.info().pages < 2)