javascript - RowGrouping and SubTotals in Sharepoint List using Datatables -


hi using sharepoint list displaying using datatables , referred 1 articles , grouping not able group totals ,rowgrouping , subtotal on datatable

in field on grouping on calculated field called heirarch example field values generaly capital.establishment concatenation of 2 fields

below code

<script type="text/javascript" charset="utf8" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>  <!-- datatables css -->  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/r/dt/dt-1.10.9/datatables.min.css"/> <!-- datatables -->  <script type="text/javascript" src="https://cdn.datatables.net/r/dt/dt-1.10.9/datatables.min.js"></script> <script type="text/javascript" src="http://jquery-datatables-row-grouping.googlecode.com/svn/trunk/media/js/jquery.datatables.rowgrouping.js"></script>  <style type="text/css">     tr.group, tr.group:hover {     background-color: #ddd !important; } .pocell {     font-weight:bold; } </style>  <table id="example" class="display" cellspacing="0" width="100%">   <thead>     <tr>      </tr>   </thead>   </table>  <script type="text/javascript">   $(document).ready(function() {          var call = $.ajax({              url: _sppagecontextinfo.webabsoluteurl + "/_api/web/lists/getbytitle('demo%20custom%20list')/items?$select=hierarch,title,year2015,year2016,year2017,year2018,year2019,exp_x0020_total",              type: "get",              datatype: "json",              headers: {                  accept: "application/json;odata=verbose"              }           });          call.done(function (data,textstatus, jqxhr){ var marker;  var table = $('#example').datatable({     "aadata": data.d.results,     "columns": [         {             "title": "hierarchy",             "mdata": "hierarch",             "visible": false           }, {             "title": "title",             "mdata": "title"         }, {             "title": "year2015",             "mdata": "year2015",             "sortable": false         }, {             "title": "year2016",             "mdata": "year2016",             "sortable": false         }, {             "title": "year2017",             "mdata": "year2017",             "sortable": false         }, {             "title": "year2018",             "mdata": "year2018",             "sortable": false         }, {             "title": "year2019",             "mdata": "year2019",             "sortable": false         }, {             "title": "total expense",             "mdata": "exp_x0020_total",             "sortable": false         }     ],     "drawcallback": function (settings) {          var api = this.api();         var rows = api.rows({             page: 'current'         }).nodes();         var last = null;         api.column(0, {             page: 'current'         }).data().each(function (group, i) {             if (last !== group) {                 $(rows).eq(i).before(                 $("<tr></tr>", {                     "class": "group",                     "data-id": group                 }).append($("<td></td>", {                     "colspan": 1,                     "class": "pocell",                     "text": "hierarch # " + group.split('_').join('.')                 })).append($("<td></td>", {                     "id": "e" + group,                     "class": "nocount",                     "text": "60.00"                 })).append($("<td></td>", {                     "id": "f" + group,                     "class": "nocount",                     "text": "60.00"                 })).append($("<td></td>", {                     "id": "g" + group,                     "class": "nocount",                     "text": "50.00"                 })).append($("<td></td>", {                     "id": "h" + group,                     "class": "nocount",                     "text": "40.00"                 })).append($("<td></td>", {                     "id": "i" + group,                     "class": "nocount",                     "text": "30.00"                 })).append($("<td></td>", {                     "id": "j" + group,                     "class": "nocount",                     "text": "20.00"                 })).prop('outerhtml'));                 last = group;             }              val = api.row(api.row($(rows).eq(i)).index()).data();                $("#e" + val.hierarch.split('.').join('_')).text(parsefloat($("#e" + val.hierarch.split('.').join('_')).text()) + parsefloat(val.year2015));          //   $("#e" + val.hierarch).text(parsefloat($("#e" + val.hierarch).text()) + val.year2015);             $("#f" + val.hierarch).text(parsefloat($("#f" + val.hierarch).text()) + val.year2015);             $("#g" + val.hierarch).text(parsefloat($("#g" + val.hierarch).text()) + val.year2015);             $("#h" + val.hierarch).text(parsefloat($("#h" + val.hierarch).text()) + val.year2015);             $("#i" + val.hierarch).text(parsefloat($("#i" + val.hierarch).text()) + val.year2015);             $("#j" + val.hierarch).text(parsefloat($("#j" + val.hierarch).text()) + val.year2015);         });     } }); });          call.fail(function (jqxhr,textstatus,errorthrown){                  alert("error retrieving tasks: " + jqxhr.responsetext);          });  } );  </script> 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -