aboutsummaryrefslogtreecommitdiff
path: root/uploader/static/js/species.js
blob: b0707253fb5187534a778fd46c34e8f1fa9f9dd3 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var speciesDataTable = (speciesdata) => {
    var lengthMenu = [10, 25, 50, 100, 1000];
    if(speciesdata.length > 1000) {
        lengthMenu.push(speciesdata.length)
    }
    $("#tbl-select-species").DataTable({
        responsive: true,
        lengthMenu: lengthMenu,
        language: {
            processing: "Processing… Please wait.",
            loadingRecords: "Loading species — Please wait.",
            lengthMenu: "Show _MENU_ species",
            info: "Showing _START_ to _END_ of _TOTAL_ species"
        },
        data: speciesdata,
        columns: [
            {
                data: (aspecies) => {
                    return `<input type="radio" name="species_id"`
                        + `id="rdo_species_id_${aspecies.SpeciesId}" `
                        + `value="${aspecies.SpeciesId}">`;
                }
            },
            {
                data: (aspecies) => {
                    return `<label for="rdo_species_id_${aspecies.SpeciesId}" `
                        + `class="control-label" style="font-weight: 1;">`
                        + `${aspecies.FullName} (${aspecies.SpeciesName})`
                        + `</label>`;
                }
            }
        ]
    });
};

$(() => {
    speciesDataTable(JSON.parse(
        $("#tbl-select-species").attr("data-species-list")));
});