G
G
GrimJack2017-05-26 17:22:16
Angular
GrimJack, 2017-05-26 17:22:16

How to make a table row a link via dataTables angular?

In general, the task is the following - to make table rows clickable.
Specifically, when you click on a line, the page should be redrawn.
The output of the table is implemented like this:

import '../../certificates/services/Certificate';
import './template.html';

angular.module('desktop').component('certificates', {
    templateUrl: NAMESPACE_DESKTOP + `components/Certificate/template.html`,
    controller: Certificates
});

function Certificates(Certificate, $stateParams) {
    $.extend($.fn.dataTable.defaults, {
        language: {
            processing: ''
        }
    });
    $('.js-datatable-certificates').dataTable({
        "processing": true,
        "ajax": '/desktop/api/certificates/' + $stateParams.record_id,
        "columns": [
            { data: 'cert_id'},
            { data: 'name' },
            { data: 'date' },
            { data: 'created_by' },
            { data: 'modified' }
        ]
    });
}

<h3>Certificates</h3>
<div class="table-responsive">
    <table class="table table-hover table-striped table-bordered js-datatable-certificates">
        <thead>
        <tr>
            <th>Certificate id</th>
            <th>Name</th>
            <th>Date</th>
            <th>Created by</th>
            <th>Modified Date</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>

Didn't work with Angular and its modules (the code is not mine, they let me finish it). Google didn't help, unfortunately. Tell me how to make the lines links. Perhaps there is a method like this for datatables or something else.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DarthJS, 2017-06-12
@DarthJS

Try to read the docs, there is a render method for each object, for rendering columns, can you try to do this? render(data) data is the data of the columns and you need to return the html element as a link with the date

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question