0

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?

Talha Junaid
  • 2,351
  • 20
  • 29
Aleksei Yerokhin
  • 869
  • 4
  • 9
  • 22
  • 1
    Finally i found it. It's managed by createdCell option like this - .withOption('createdCell', withCreatedActionsCell). How in the world could i miss this.... – Aleksei Yerokhin Nov 25 '15 at 15:35
  • You should produce an answer yourself and mark it as accepted. I am sure it could help people in the future ... – davidkonrad Jan 26 '16 at 17:30

1 Answers1

0

Finally i found it. It's managed by createdCell option like .withOption('createdCell', withCreatedActionsCell).

Talha Junaid
  • 2,351
  • 20
  • 29
Aleksei Yerokhin
  • 869
  • 4
  • 9
  • 22