aboutsummaryrefslogtreecommitdiff
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")));
});