java - Print a list as a table in jsp -


I have one such list:

  [[A, 0,1], [A, 0,0], [b1,1], [c, 1,1], [c, 0,1]]   

and I would like to print it like this In HTML:

  ------------- | A. 0 | 1 | - - ----- | | | 0 | ------------- | B 0 | 1 | ------------- | C. 1 | 1 | --------- | | 0 | 1 | -------------   

Is there a way to do this in JavaScript or is it an easy way to do this in jsp?

javascript:

source:

  var arr = [['A', 0,1], ['A', 0,0], ['B', 0,1], ' C ', 1, 1], [' C ', 0,1]];   

Calculate the merge depth for each cell:

  var depth = arr. Map (function (item) {return item.map (function () {return 0;})}} var arrLength = arr.length; (var index = 0; index   

Results table: < / Strong>

  var tableHTML = '& lt; Table & gt;' (Var i = 0; i & lt; subArr.length; i ++) {var iDepth = Depth [index ] [I]; + arr.map for function (function (all ARR, index) {var str = '& lt; Tr & gt; (IDepth! == -1) {str + = '& lt; Td '+ (iDepth> 0?' Rowspan = '' (iDepth + 1 + '' '': '') + '& gt; + SubAer [I] + '';}} return str + '';}). Join ('') + '& lt; / table & Gt; ';   

Demo:

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -