Table in a project is now implemented like this:
<table datatable="" dt-options="vm.dtOptions" dt-columns="vm.dtColumns" class="table table-custom"></table>
The code related to this table:
vm.dtColumns = [
DTColumnBuilder.newColumn('id', 'Login ID'),
DTColumnBuilder.newColumn('username', 'User Name'),
DTColumnBuilder.newColumn('email', 'Email'),
DTColumnBuilder.newColumn('usergrouproles', 'User Group Role'),
DTColumnBuilder.newColumn(null).withOption('defaultContent', '<button>button1</button><button>button2</button>').notSortable(),
DTColumnBuilder.newColumn(null).withOption('defaultContent', '<button>button3</button><button>button4</button><button>button5</button>').notSortable()
];
vm.dtOptions = DTOptionsBuilder
.newOptions()
.withBootstrap()
.withFnServerData(serverData)
.withDataProp('data')
.withOption('processing', true)
.withOption('serverSide', true)
.withOption('paging', true)
.withOption('rowCallback', function(row, data, index){
console.log("test rowCallback");
})
function serverData(sSource, aoData, fnCallback, oSettings) {
var draw = aoData[0].value;
var _order = aoData[2].value[0].dir.toUpperCase();
var _start = aoData[3].value;
var _end = _start + aoData[4].value;
var _sort = aoData[1].value[aoData[2].value[0].column].data;
UserSvc.getUsersPaginated(_start, _end, _order, _sort).then(function(result){
var records = {
'draw': draw,
'recordsTotal': result.length,
'recordsFiltered': result.totalCount,
'data': result
};
fnCallback(records);
});
}
For now, it seems okay except the User Group Role
column - data there is in form of the object that is why I need to expand it there using ng-repeat
. I'm aware of initComplete
callback that I will be to apply finally but i cannot get how would I perform expand itself. I mean i want to operate in each cell but i have only an access to the whole row. I gave a try a renderWith()
function in vm.dtColumns
but it doesn't work at all. Could you show me the right direction?