Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

My angularjs controller code for datatable is given below. With DTColumnBuilder option how can i provide column renderer to show formatted data

$scope.dtOptions = DTOptionsBuilder.fromSource(CompanyService.loadUrl()).withPaginationType('full_numbers').withOption('rowCallback', rowCallback);
$scope.dtColumns = [
    DTColumnBuilder.newColumn('id').withTitle('Id'),
    DTColumnBuilder.newColumn('name').withTitle('Name'),
    DTColumnBuilder.newColumn('description').withTitle('Description'),
    DTColumnBuilder.newColumn('active_status').withTitle('Status')
];
share|improve this question

The link which help me to write renderer https://github.com/l-lin/angular-datatables/issues/224

    $scope.dtColumns = [
    DTColumnBuilder.newColumn('id').withTitle('Id'),
    DTColumnBuilder.newColumn('name').withTitle('Name'),

    DTColumnBuilder.newColumn(null).withTitle('Address').renderWith(function(data,type,full) {
        var address =  '<address>' + data.address_line_1+ '<br>';
        if (data.address_line_2.trim())  {
            address = address + data.address_line_2+ '<br>';
        }       
        address = address + data.location + '<br>'
                 + data.city + '-' + data.pincode + '<br>'
                 + data.state +'<br>' 
                 + data.country;
        return address;         

    }),

    DTColumnBuilder.newColumn('city').withTitle('City'),
    DTColumnBuilder.newColumn('state').withTitle('State'),
    DTColumnBuilder.newColumn('country').withTitle('Country'),
];
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.