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

222
Visualizações
Kendo Grid Cancel event restores hidden buttons

I have a Kendo grid with row buttons that I hide depending on users accessing the page: for certain users, only "Edit" button will be visible, while for others "Delete" and "Add" buttons will be visible. I do this with a function that, after checking user and their permissions, hides the buttons like this:

            $("#grid").find(".k-grid-delete").hide();
            $("#grid").find(".k-grid-edit").show();
            $("#grid").find(".k-grid-add").hide();

This is working fine, but if a user with only the Edit button visible clicks on Edit and then clicks the Cancel button, the grid restores itself to "normal" and all the buttons are visible. I've tried intercepting the "Cancel" event, and call the function that hids the buttons there, but the redraw of the grid apparently happens AFTER the cancel event is finished. I've tried with databound, but the databound is not raised when the action is cancelled. I need to intercept an event that happens after "Cancel" is clicked and before the grid is redrawn.

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In the end it was simpler to build the toolbar and command options with a function than to remove conditionally certain buttons after building the grid. That is, in the kendo grid definition function:

var grid = $("#grid").kendoGrid({
                        dataSource: dataSource,
                        toolbar: setToolbarCreateButton(),
                        columns: [
                            { field: "COL1" },
                            { field: "COL2" },
                            { field: "COL3" },
                            {
                                command: setCommandRow(),
                                title: " ",
                                width: "250px"
                            }
                        ],
                        (rest of configuration here)
                    });

And in the functions setCommandRow() and setToolbarCreateButton() return the definition of the buttons depending on the conditions:

        // Returns an array of objects with the buttons for the command bar IF those buttons are visible
    function setToolbarCreateButton() {
        if (checkEditable(false)) return [{ name: "create" }];
        else return null;
    }

and

        // Returns an array of objects with the buttons for the row IF those buttons are visible
    function setCommandRow() {
        var cmdRow = [];
        if (checkEditable(true)) cmdRow.push({ name: "edit" });
        if (checkEditable(false)) cmdRow.push({name: "destroy" });
        return cmdRow;
    }

checkEditable() is, of course, the method that determines if the edit or destroy buttons are available or not. In this way instead of making the buttons visible or invisible I create the buttons or not depending on the conditions.

about 4 years ago · Juan Pablo Isaza 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