javascript - Add border around specific rows in a Table -



javascript - Add border around specific rows in a Table -

col1 col2 col3 col4 col5 col6 row11 row12 row13 row14 row15 row16 row21 row22 row23 row24 row25 row26 row31 row32 row33 row34 row35 row36

i wish add together border around entire row or specific row, column combination (col4) first column values equal. example, if row11 equal row21, either there should border around 2 rows or around row14, row24. highly appreciate if can provide recommendations around same.

it not hard iterate on first cell of each row determine if cell content "equal" content of first cell in next row, have function homecoming array of matching rows, e.g.

// homecoming array of arrays of row indexes // first cell content equal function getmatchingrows(table) { var rows = table.rows; var allmatches = []; var currentmatches, currentvalue, previousvalue; (var i=0, ilen=rows.length; i<ilen; i++) { currentvalue = gettext(rows[i].cells[0]); if (currentvalue == previousvalue) { if (!currentmatches) { currentmatches = [i-1, i]; } else { currentmatches.push(i); } } else { previousvalue = currentvalue; if (currentmatches) { allmatches.push(currentmatches); currentmatches = null; } } } homecoming allmatches; } // simple function homecoming element's text content function gettext(el) { if (typeof el.textcontent == 'string') { homecoming el.textcontent; } else if (typeof el.innertext == 'string') { homecoming el.innertext; } }

now it's matter of applying appropriate style cells, need hightlighrows function hightlights rows based on row index array, , hightlightcolumnsegment highlights cells based on same row index array , cell index (or perhaps multiple cell indexes if want highlight blocks of adjacent columns , rows).

the gettext function simplistic, sufficient example.

javascript jquery html jsp

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -