Skip to content Skip to sidebar Skip to footer

Datatable Is Not Generating After Call Function In Angular Js

I am displaying data in datatable. So when I land on the page without function call than it is working but when I want to generate datatable after calling function than it is not w

Solution 1:

Try to initialized this.standardOptions at the begining

this.standardOptions = {};
$scope.tableCall=function(){
   angular.extend(this.standardOptions, DTOptionsBuilder
  .fromFnPromise(call.all('------API----------').getList())
  .withDOM("<'dt-toolbar'<'col-xs-12 col-sm-6'f><'col-sm-6 col-xs-12 hidden-xs'l>r>" +
  "t" +
  "<'dt-toolbar-footer'<'col-sm-6 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-6'p>>")
  .withBootstrap());
this.standardColumns = [
    DTColumnBuilder.newColumn('name').withOption('defaultContent','-'),
    DTColumnBuilder.newColumn('age').withOption('defaultContent','-'),
    DTColumnBuilder.newColumn('section').withOption('defaultContent','-'),
    DTColumnBuilder.newColumn('gender').withOption('defaultContent','-'),
  ];
}

Another things seems strange. standardOptions is defined on this but tableCall function is defined on $scope. In your DOM, do you use ng-controller with 'as' keyword ? Check if you should use $scope or this. I think there is a mistake here.

Post a Comment for "Datatable Is Not Generating After Call Function In Angular Js"