HTMLTableElement deleteRow method

Definition

The HTMLTableElement.deleteRow() method removes a specific row (<tr>) from a given <table>.

Example

 1 /**
 2  * Suppression d'une ligne lorsque le temps imputé === '00:00'
 3  *
 4  */
 5 function trt_temps_impute_0(value_temps_impute, element) {
 6     if (value_temps_impute === "00:00") {
 7         // https://gdevops.frama.io/web/linkertree/html/apis/element/element.html
 8         // https://gdevops.frama.io/web/linkertree/html/apis/element/table/table.html
 9         // https://gdevops.frama.io/web/linkertree/html/apis/HTMLTableElement/HTMLTableElement.html
10         const table = document.getElementById('id_list_table');
11         // https://gdevops.frama.io/web/linkertree/html/apis/node/properties/parentElement/parentElement.html
12         // https://gdevops.frama.io/web/linkertree/html/apis/element/tr/tr.html
13         const element_tr = element.parentElement.parentElement.parentElement;
14         // https://gdevops.frama.io/web/linkertree/html/apis/HTMLTableRowElement/properties/rowIndex/rowIndex.html
15         // https://gdevops.frama.io/web/linkertree/html/apis/HTMLTableElement/methods/deleteRow/deleteRow.html
16         table.deleteRow(element_tr.rowIndex);
17     }
18 }
19
20 function trt_temps_imputes() {
21     console.log(`trt_temps_imputes() document.readyState = ${document.readyState}`);
22     const url = '{% url "fiches_temps:ajax_update_fiche_temps" %}';
23     const current_iso_week = document.getElementById('id_current_iso_week').innerHTML;
24     const parameters = {'current_iso_week': current_iso_week};
25
26     let value_temps_impute = null;
27     {% for v, _, _ in listes_des_projets_fiches %}
28         document.getElementById('id_fiches_temps_{{ v }}-temps_impute').onchange = function() {
29           value_temps_impute = document.getElementById('id_fiches_temps_{{ v }}-temps_impute').value;
30           parameters.temps_impute = get_temps_impute(value_temps_impute);
31           parameters.fiche_temps_id = document.getElementById('id_fiches_temps_{{ v }}-id').value;
32           parameters.projet_id = document.getElementById('id_fiches_temps_{{ v }}-projet').value;
33           parameters.employe_id = document.getElementById('id_fiches_temps_{{ v }}-employe').value;
34           parameters.created = document.getElementById('id_fiches_temps_{{ v }}-created').value;
35           id3_fetch(url, parameters).then(json => {
36                 document.getElementById('id_fiches_temps_{{ v }}-id').value= json.fiche_temps_id;
37                 document.getElementById('id_fiches_temps_{{ v }}-created').value = json.created;
38                 document.querySelector("#cumul_day").innerHTML = json.daily_hours_for_employe;
39
40                 trt_temps_impute_0(value_temps_impute, this);
41           });
42         }
43     {% endfor %}
44 }