-
Notifications
You must be signed in to change notification settings - Fork 488
Delay render to define dtColumns using promises #22
Comments
I don't think it's a good idea to add more complexity to the module. Maybe there is an another way to solve your problem, like loading your column options before rendering the template where your DataTable is. |
I have the same problem, I need define which columns to display by server side request. |
I made a workaround for this problem. I just set the table to display after columns are defined... <table ng-if="showDT" datatable dt-options="dtOptions" dt-columns="dtColumns"></table> //options definitions
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('ajax', { url: 'http://localhost/data.json' });
//coluns definitions
var dtColumns = [];
//request columns config
$http.get('http://localhost/config-columns.json').
success(function(data) {
// this callback will be called asynchronously
angular.forEach(data, function(column){
dtColumns.push(DTColumnBuilder.newColumn(column.Name));
});
});
//set columns
$scope.dtColumns = dtColumns;
//show datatable
$scope.showDT = true; It may be weird, but works for me! |
I'm considering accepting a promise in the |
Sure! |
I also need this functionality |
I have to say, I found the right thread for my problem. Basically ng-repeat on thead th is not going to be resolved before the directive is rendered. So I'll try the above approaches. |
Hey Louis,
I have a scenario where my DTColumns are defined by rules on server side, that returns an array with columns. I'm getting a error because datatables rendering cannot wait for columns definition (like the behaviour support for data) arriving after controller execution.
My ideia is to implement support to define columns using promises, alongside "static" way, through a delay on datatables rendering.
What you think? Any advices?
The text was updated successfully, but these errors were encountered: