I have data of matrix stored in table as below tables:
- MatrixDimensions -
MatrixId, NoOfRows, NoOfCol
- MatrixValues -
MatrixId, RowNo, ColNo, Value
How can I make jqGrid
to take no. of rows & columns dynamically
and also display the serialized data in matrix? Is there a direct way or will I have to implement for
loops to upload the data in matrix?
Can I display rows as columns and columns as rows (so having column headers vertically aligned)?
Can I enable only inline editing and disable form based editing?
I just wrote the answer to another question where I described how to create the grid with dynamic number of columns (number of rows is always dynamic in jqGrid). It seems to me this way you can display any matrix. In you case you can probably make the code simpler because you can use generic column names like "1", "2", etc. (or "Col. 1", "Col. 2", etc.) and so on.
I modified the code so that it uses array of arrays (matrix) instead of the array on objects with named properties. So jqGrid will looks like this:
or this:
depending on the input
JSON
data.The full demo can be found here. The full JavaScript code of the demo you can find below:
The simplest way to transpose the matrix (reflect it over its main diagonal) is on the server. If you can't do this, you can create and fill the transposed matrix inside of
page
function (see my code above) and just replace therow
part of theobj
with the transposed matrix.