HTMLTableRowElement rowIndex property ¶
See also
Definition ¶
The HTMLTableRowElement.rowIndex read-only property represents the position of a row in relation to the whole <table>.
Even when the <thead>, <tbody>, and <tfoot> elements are out of order in the HTML, browsers render the table in the right order.
Therefore the rows count from <thead> to <tbody>, from <tbody> to <tfoot>.
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.gitlab.io/tuto_web/html/apis/element/element.html
8 // https://gdevops.gitlab.io/tuto_web/html/apis/element/table/table.html
9 // https://gdevops.gitlab.io/tuto_web/html/apis/HTMLTableElement/HTMLTableElement.html
10 const table = document.getElementById('id_list_table');
11 // https://gdevops.gitlab.io/tuto_web/html/apis/node/properties/parentElement/parentElement.html
12 // https://gdevops.gitlab.io/tuto_web/html/apis/element/tr/tr.html
13 const element_tr = element.parentElement.parentElement.parentElement;
14 // https://gdevops.gitlab.io/tuto_web/html/apis/HTMLTableRowElement/properties/rowIndex/rowIndex.html
15 // https://gdevops.gitlab.io/tuto_web/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 }