I'm working with datatables and I want to fill a table with dynamic columns. The columns will be display according to the "Order" property. The rows are mapped to the columns by the property "Id_Col" and the "RowIdx" corresponds to the index of the row. I want to populate the datatable options :"columns" and "data" My json object is as follows :
I hope to have your help. Thank you in advance!
{
"Col": [
{
"Id_Col": 1,
"Col_Name": "Col 1",
"Order": 1
},
{
"Id_Col": 2,
"Col_Name": "Col 2",
"Order": 2
},
{
"Id_Col": 3,
"Col_Name": "Col 3",
"Order": 3
},
{
"Id_Col": 4,
"Col_Name": "Col 4",
"Order": 4
}
],
"Row": [
{
"Id_Col": 1,
"RowIdex": 1,
"Val": "Row 1 col 1"
},
{
"Id_Col": 2,
"RowIdex": 1,
"Val": "Row 1 col 2"
},
{
"Id_Col": 3,
"RowIdex": 1,
"Val": "Row 1 col 3"
},
{
"Id_Col": 4,
"RowIdex": 1,
"Val": "Row 1 col 4"
},
{
"Id_Col": 1,
"RowIdex": 2,
"Val": "Row 2 col 1"
},
{
"Id_Col": 2,
"RowIdex": 2,
"Val": "Row 2 col 2"
},
{
"Id_Col": 3,
"RowIdex": 2,
"Val": "Row 2 col 3"
},
{
"Id_Col": 4,
"RowIdex": 2,
"Val": "Row 3 col 4"
},
{
"Id_Col": 1,
"RowIdex": 3,
"Val": "Row 3 col 1"
},
{
"Id_Col": 2,
"RowIdex": 3,
"Val": "Row 3 col 1"
},
{
"Id_Col": 3,
"RowIdex": 3,
"Val": "Row 3 col 2"
},
{
"Id_Col": 4,
"RowIdex": 3,
"Val": "Row 3 col 3"
}
]
}