Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
Is there a way to disable the month/viewmode button in bootstrap-datetimepicker?

I've updated bootstrap from version 3 to 4 and noticed the calendar is overlapping when creating it with js instead of cshtml. There's no need to go back more than a few days so I would like to disable the month button that changes the view mode to months or years. Is there a specific CSS property that I need or would I need to edit a code in the library?

viewmode normal

viewmode overlapped

function AddDateTimeControl(parent, control, rowIndex, controlIndex) {
    var dateTimeID = "datetimepicker" + controlIndex;

    var tooltipDiv = CreateTooltipDiv();
    var tooltipSpan = CreateTooltipSpan(control.ToolTip);
    var label = CreateControlLabel(control);
    //var icon = CreateIcon('fa-calendar');
    var icon = CreateIcon("calendar-alt-regular");

    tooltipDiv.appendChild(label);
    tooltipDiv.appendChild(icon);
    tooltipDiv.appendChild(tooltipSpan);

    var dateDiv = document.createElement("div");
    dateDiv.classList.add('input-group');
    dateDiv.classList.add('date');
    dateDiv.classList.add('date-time-control');
    dateDiv.style.color = "black";
    dateDiv.id = dateTimeID;

    var dateTextBox = document.createElement("input");
    dateTextBox.type = "text";
    dateTextBox.classList.add("form-control");
    dateTextBox.value = control.RawValues[0];

    MarkElementForSerialization(dateTextBox, rowIndex, control.ID, 0);

    var calControlSpan = document.createElement("span");
    calControlSpan.classList.add('input-group-append'); //input-group-addon?
    //span -> fa-calendar?

    dateDiv.appendChild(dateTextBox);
    dateDiv.appendChild(calControlSpan); //input-group-addon

    parent.appendChild(tooltipDiv);
    parent.appendChild(dateDiv);

    $(dateDiv).datetimepicker();
    $(dateDiv).data("DateTimePicker").sideBySide(true);
    $(dateDiv).data("DateTimePicker").date(new Date(Date.parse(control.RawValues[0])));
    $(dateDiv).data("DateTimePicker").format("MM/DD/YYYY HH:mm");
    $(dateDiv).data("DateTimePicker").icons({
        time: "fa fa-clock-o",
        date: "fa fa-calendar",
        up: "fa fa-arrow-up",
        down: "fa fa-arrow-down",
        previous: "fa fa-chevron-left",
        next: "fa fa-chevron-right",
        today: "fa fa-clock-o",
        clear: "fa fa-trash-o"
    });

    $(dateTextBox).on('click', function() {
        $(dateDiv).data("DateTimePicker").toggle();
    });
}
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

That will depend entirely on which datetimepicker component you are using.

This one lets you set the maximum view:

$(dateDiv).datetimepicker({ maxView: 1 })

However, it was never updated to support Bootstrap 4.

That picker has since been deprecated in favour of eonasdan-bootstrap-datetimepicker, which has an option to set the minimum view, but not the maximum view. You would need to dig in to the code for that version if you wanted to add that option.

There is a newer version of the Eonasdan picker, now called tempus dominus, which is currently in alpha. That version provides options to turn the individual views on or off:

$(dateDiv).tempusDominus({
   display: {
     viewMode: 'date',
     components: {
       decades: false,
       year: false,
       month: false,
       date: true,
       hours: true,
       minutes: true,
       seconds: false
     }
   }
})
over 4 years ago · Santiago Trujillo Relatório

0

I ended up disabling it by disabling the pointer event in the month picker switch.

th.picker-switch[title="Select Month"] {
    pointer-events: none;
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda