how to reload the datatable server side processing in button click event using angular 7

how to reload the datatable server side processing in button click event using angular 7

hemanthkumarhemanthkumar Posts: 5Questions: 2Answers: 0

when i click the button in datatable after operation of that event datatable has to reload to new show new data's

Answers

  • hemanthkumarhemanthkumar Posts: 5Questions: 2Answers: 0
    edited July 12
    const that = this;
    
        this.dtOptions = {
          pagingType: 'full_numbers',
          responsive: true,
          serverSide: true,
          processing: true,
          scrollY: '400',
          ajax: (dataTablesParameters: any, callback) => {
            console.log(dataTablesParameters.order[0].dir);
            this.noOfRows = dataTablesParameters.length.toString();
            const page = parseInt(dataTablesParameters.start) / parseInt(dataTablesParameters.length) + 1;
            this.pageNo = page.toString();
            dataTablesParameters.PageNo = page.toString();
            dataTablesParameters.NoOfRows = dataTablesParameters.length.toString();
            dataTablesParameters.SearchValue = dataTablesParameters.search.value;
            dataTablesParameters.sortHeader = this.sortHeader;
            dataTablesParameters.sortOrder = dataTablesParameters.order[0].dir;
            that.http
              .post<DataTablesResponse>(
                this.config.integrationGridList,
                dataTablesParameters, {}
              ).subscribe(resp => {
                console.log(resp);
                that.tableData = resp.result.lists;
                callback({
                  recordsTotal: resp.result.totalRowsOfTable[0].totalCount,
                  recordsFiltered: resp.result.totalRowsOfTable[0].totalCount,
                  data: []
                });
              });
          },
    
          dom: 'lBfrtip',
          buttons: [
            {
              extend: 'collection',
              text: 'Export',
              buttons: [
                'copy',
                'excel',
                'csv',
                'pdf',
              ]
            }
          ],
          columnDefs: [
            {  data: 'Company' },
            {  data: 'FTP Host'},
            {  data: 'Ftp Incoming Directory' },
            {  data: 'Ftp Processed Directory'},
            {  data: 'Ftp Failed Directory' },
            {  data: 'Action', 'orderable': false, targets: -1},
          ],
    
        };
    

    Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • colincolin Posts: 5,407Questions: 0Answers: 940

    Hi @hemanthkumar ,

    I'm not clear what your issue, sorry. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • hemanthkumarhemanthkumar Posts: 5Questions: 2Answers: 0

    ok thank you colin

Sign In or Register to comment.