Each loop in "columns" property

Each loop in "columns" property

Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0

Ok so I have implemented dataTable in MVC , I have a problem in which I need to update dataTable columns based on a javascript array, is there any solution to accomplish something like this when declaring dataTable?

      @foreach (var header in  @<text>depList</text>)
                    {

                          <text>
                             { "data": "@header.mainDept", "autowidth": true, "orderable": false, render: $.fn.dataTable.render.number(",")},
                          </text>

                     }

I would like something like this

    $.each (obj, function(key,value){

       { "data": value, "autowidth": true, "orderable": false, render: $.fn.dataTable.render.number(",")},
    }
This discussion has been closed.