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

@@ -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)