import React, { useEffect } from 'react' import { Button, Card, Col, Container, Row } from 'react-bootstrap'; import { TabulatorFull as Tabulator } from 'tabulator-tables'; import '../jqueryloader' const exportcsv = '/images/contacts/Excel.svg'; const gridEditIcon = '/images/refine_by_icons/edit.svg'; const gridDeleteIcon = '/images/cross_gray.svg'; var tablePaymentsGrid = ''; var toggleValue = ''; const groupByHCP = () => { function toggleKolGrouping(){ toggleValue = $("#toggleKolGrouping").text(); if(toggleValue == 'Remove Grouping'){ tablePaymentsGrid.setGroupBy(false); $("#toggleKolGrouping").text("Group By HCP"); }else{ tablePaymentsGrid.setGroupStartOpen(false); tablePaymentsGrid.setGroupBy("kol_name"); $("#toggleKolGrouping").text("Remove Grouping"); } } function listPayments(){ //Tabulator Grid parameters var gridFor='payments'; var gridHeaderText= "Payments"; var gridId= gridFor+'-grid-table'; var actionLink = "
"; actionLink += "
"; //Data for grid to load var tableData2 = [ {micro:'1',kol_name:'Aaron James Miller',date:"14/05/2020",type: "General",amount: "555.00",status: "Completed",act:''}, {micro:'2',kol_name:'Aaron James Miller',date:"20/05/2020",type: "General",amount: "550.00",status: "Completed",act:''}, {micro:'3',kol_name:'Aaron James',date:"14/05/2020",type: "General",amount: "555.00",status: "Completed",act:''}, {micro:'4',kol_name:'Aaron James',date:"20/05/2020",type: "General",amount: "550.00",status: "Completed",act:''}, ] //Tabulator Gird initialisation tablePaymentsGrid = new Tabulator("#"+gridId, { //var tableData = ; data:tableData2, columns:[ {title:"#", formatter:'rownum',align:'center',headerSort:false,tooltip:false, width:"5%"}, {title:"", field:"micro",formatter:function(cell, formatterParams, onRendered){ return "
"; //return the contents of the cell; },headerFilter:false,headerSort:false,align:'center', width:"5%"}, {title:"HCP Name", field:"kol_name",formatter:function(cell, formatterParams, onRendered){ return "" + cell.getValue() + ""; //return the contents of the cell; },headerFilter:true, headerFilterPlaceholder:'Search', align:'left', width:"42%"}, {title:"Date", field:"date",headerFilter:true, headerFilterPlaceholder:'Search', align:'left', width:"10%"}, {title:"Type", field:"type",headerFilter:true, headerFilterPlaceholder:'Search', align:'left', width:"10%"}, {title:"Amount", field:"amount",headerFilter:true, headerFilterPlaceholder:'Search', align:'left',bottomCalc:"sum", width:"10%"}, {title:"Status", field:"status",headerFilter:true, headerFilterPlaceholder:'Search', align:'left', width:"10%"}, {title:"Action", field:"act",formatter:function(cell, formatterParams){ return actionLink; },headerFilter:false,headerSort:false,width:80,align:'center', width:"8%"} ], layout:"fitDataStretch", tooltips:true, ajaxSorting:false, ajaxFiltering:false, initialSort:[{column:"date", dir:"desc"}], groupClosedShowCalcs:true, paginationSize:10, // this option can take any positive integer value (default = 10),possible values 10,20,50,100 pagination:"local", paginationSizeSelector:[10, 20, 50, 100], tableBuilt:function(){ $("#"+gridFor+"-grid-header .grid-header-text").html(gridHeaderText); } }); var grid_options ='
 
'; grid_options +='
Add Payments
'; $("#"+gridFor+"-grid-header .grid-header-text").append(grid_options); } useEffect(()=>{ listPayments(); }, []) return ( <> Custom Tabulator
csv
) } export default groupByHCP