title: List to Jquery Datatable c#
body: <p>I'm trying to make my List to fill my jquery Datatable but I'm unable to do so, at the moment im writing my list to a file to access it by datatable in my <code>view-model</code> is my approach the correct one?</p>
  
  <p>This is my code:</p>
  
  <pre><code>List&lt;string&gt; list = new List&lt;string&gt;();
  foreach (var item in db.Pos)
  {
     var total = 0;
     decimal costo = 0;
  
     for (int i = 1; i &lt;= 31; i++)
     {
        var value = 0;
        if (item.Fecha.Day == i) { value = item.Cantidad; costo = costo + item.Total; }
        total += value;
     }
  
     list.Add(item.Descripcion);
     list.Add(item.Pdv);
     list.Add(item.Rid);
     list.Add(((costo / (total + 1)).ToString("C")));
  
     for (int i = 1; i &lt;= 31; i++)
     {
        var value = 0;
        list.Add(value.ToString());
        int month = item.Fecha.Month;
        if (item.Fecha.Day == i) { value = item.Cantidad; list.Add(value.ToString()); }                                                
     }
  
     list.Add(total.ToString());
     list.Add((((costo / (total + 1)) * total).ToString("C")));
  }
  
  var json = JsonConvert.SerializeObject(new List&lt;object&gt;() { list });
  System.IO.File.WriteAllText(@"\path.txt", json);
  </code></pre>
  
  <p>And my Datatable Ajax Call:</p>
  
  <pre><code>$(document).ready(function () {
     var table = $('#pftable_hdr').DataTable({
      ajax: {
        url: "/path.txt",
        dataSrc: ""
      },
      scrollY: "500px",
      scrollX: true,
      scrollCollapse: true,
      fixedColumns: {
        leftColumns: 3
      }
    });
  });
  </code></pre>
  
  <p>Part of my Txt File Output:</p>
  
  <pre><code>[["ENS FRUTAS","REST","CENAS","$26.50","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","$26.50","CAFE AMER ILIMIT","REST","CENAS","$11.50","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","$11.50","QUESADILLAS TRAD (2)","REST","CENAS","$25.50","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","$25.50"]]
  </code></pre>
  
  <p>How can I fill my Jquery datatable with my list? My text file should have <code>[]</code> before and after the <code>$data</code> but I can't make that happen only at the first of the file and in the end.</p>