N°2847 - Tranform old itop datatable to jquery DataTable - Fix management of button "Add" step 2

This commit is contained in:
acognet
2020-11-24 14:21:28 +01:00
parent ad19a89fc5
commit fb70026966

View File

@@ -174,7 +174,6 @@ var oTable{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').DataTable({
{% if oUIBlock.GetOption("select_mode") is not empty %} {% if oUIBlock.GetOption("select_mode") is not empty %}
{% if oUIBlock.GetOption("select_mode") != "single" %} {% if oUIBlock.GetOption("select_mode") != "single" %}
console.warn('aa');
oTable{{ oUIBlock.GetId() }}.off('select').on('select', function (oEvent, dt, type, indexes) { oTable{{ oUIBlock.GetId() }}.off('select').on('select', function (oEvent, dt, type, indexes) {
var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray(); var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
if( $(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") if( $(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative")
@@ -242,8 +241,32 @@ oTable{{ oUIBlock.GetId() }}.off('deselect').on('deselect', function (oEvent, dt
}); });
{% else %} {% else %}
oTable{{ oUIBlock.GetId() }}.off('select').on('select', function (oEvent, dt, type, indexes) { oTable{{ oUIBlock.GetId() }}.off('select').on('select', function (oEvent, dt, type, indexes) {
var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
// Checking input
$('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true);
// Saving values in temp array
for (var i in aData) {
var iItemId = aData[i].id;
if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) === -1) {
oSelectedItems{{ oUIBlock.GetOption('sListId') }}.push(iItemId);
}
}
$('#btn_ok_{{ oUIBlock.GetOption('sListId') }}').prop('disabled', false); $('#btn_ok_{{ oUIBlock.GetOption('sListId') }}').prop('disabled', false);
}); });
oTable{{ oUIBlock.GetId() }}.off('deselect').on('deselect', function (oEvent, dt, type, indexes) {
var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
// Checking input
$('#{{ oUIBlock.GetId() }} tr[role="row"]:not(.selected) td:first-child input').prop('checked', false);
// Saving values in temp array
for (var i in aData) {
var iItemId = aData[i].id;
if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) > -1) {
oSelectedItems{{ oUIBlock.GetOption('sListId') }}.splice(oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId), 1);
}
}
});
{% endif %} {% endif %}
{% endif %} {% endif %}