c# - Add Serialized List to jquery Datatables -
i'm trying add serialized list in .txt file , add jquery datatable using ajax call, got error in first line of ajax. can tell me i'm doing wrong?
this path.txt (serialized list):
["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"]
this datatable-filling javascript:
$(document).ready(function () { var table = $('#pftable_hdr').datatable({ "ajax": { "url": "/path.txt", "datasrc": "" }, "columns": [ { "data": "descripcion" }, { "data": "pdv" }, { "data": "rid" }, { "data": "pv" }, { "data": "1" }, { "data": "2" }, { "data": "3" }, { "data": "4" }, { "data": "5" }, { "data": "6" }, { "data": "7" }, { "data": "8" }, { "data": "9" }, { "data": "10" }, { "data": "11" }, { "data": "12" }, { "data": "13" }, { "data": "14" }, { "data": "15" }, { "data": "16" }, { "data": "17" }, { "data": "18" }, { "data": "19" }, { "data": "20" }, { "data": "21" }, { "data": "22" }, { "data": "23" }, { "data": "24" }, { "data": "25" }, { "data": "26" }, { "data": "27" }, { "data": "28" }, { "data": "29" }, { "data": "30" }, { "data": "31" }, { "data": "total" }, { "data": "cantidad" } ], scrolly: "500px", scrollx: true, scrollcollapse: true, fixedcolumns: { leftcolumns: 3 } }); });
and html table code:
<table class="table table-hover no-more-tables table-iconmebanquet-detail" id="pftable_hdr"> <thead> <tr> <th style="">descripcion</th> <th style="">pdv</th> <th style="">rid</th> <th style="">pv</th> <th style="">1</th> <th style="">2</th> <th style="">3</th> <th style="">4</th> <th style="">5</th> <th style="">6</th> <th style="">7</th> <th style="">8</th> <th style="">9</th> <th style="">10</th> <th style="">11</th> <th style="">12</th> <th style="">13</th> <th style="">14</th> <th style="">15</th> <th style="">16</th> <th style="">17</th> <th style="">18</th> <th style="">19</th> <th style="">20</th> <th style="">21</th> <th style="">22</th> <th style="">23</th> <th style="">24</th> <th style="">25</th> <th style="">26</th> <th style="">27</th> <th style="">28</th> <th style="">29</th> <th style="">30</th> <th style="">31</th> <th style="">total</th> <th style="">venta</th> </tr> </thead> <tfoot> <tr> <th style="">descripcion</th> <th style="">pdv</th> <th style="">rid</th> <th style="">pv</th> <th style="">1</th> <th style="">2</th> <th style="">3</th> <th style="">4</th> <th style="">5</th> <th style="">6</th> <th style="">7</th> <th style="">8</th> <th style="">9</th> <th style="">10</th> <th style="">11</th> <th style="">12</th> <th style="">13</th> <th style="">14</th> <th style="">15</th> <th style="">16</th> <th style="">17</th> <th style="">18</th> <th style="">19</th> <th style="">20</th> <th style="">21</th> <th style="">22</th> <th style="">23</th> <th style="">24</th> <th style="">25</th> <th style="">26</th> <th style="">27</th> <th style="">28</th> <th style="">29</th> <th style="">30</th> <th style="">31</th> <th style="">total</th> <th style="">venta</th> </tr> </tfoot> </table>
how can make ajax call fill datatable data in .txt file?
your data has array of arrays, see below:
[["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"]]
there no need columns.data
initialization options, see updated javascript code below:
$(document).ready(function () { var table = $('#pftable_hdr').datatable({ ajax: { url: "/path.txt", datasrc: "" }, scrolly: "500px", scrollx: true, scrollcollapse: true, fixedcolumns: { leftcolumns: 3 } }); });
see this jsfiddle code , demonstration.
Comments
Post a Comment