Pular para o conteúdo principal

ASPxDocumentViewer ASPxRibbon ExternalRibbon Hidden Buttons Export

Como ocultar os botões de exportar e salvar da barra do Toolbar (Ribbon) do controle ASPxRibbon  do DevExpress.

Vamos lá...

Crie uma página .aspx e adicione o controle DocumentViewer

<dx:ASPxDocumentViewer ID="ASPxDocumentViewer1" runat="server" ToolbarMode="ExternalRibbon" AssociatedRibbonID="ASPxRibbon1">
                </dx:ASPxDocumentViewer>

Modifique o atributo ToolbarMode para ExternalRibbon e defina o nome do controle Ribbon que será associado ao DocumentViewer, propriedade AssociatedRibbonID, como destacado no código acima.

Código do controle Ribbon usado pelo DocumentViewer:

<dx:ASPxRibbon ID="ASPxRibbon1" runat="server" EnableTheming="True" OnInit="ASPxRibbon1_Init">
        <Tabs>
            <cc1:DocumentViewerHomeRibbonTab>
                <Groups>
                    <cc1:DocumentViewerPrintRibbonGroup>
                        <Items>
                            <dx:DocumentViewerPrintReportRibbonCommand>
                            </dx:DocumentViewerPrintReportRibbonCommand>
                            <dx:DocumentViewerPrintPageRibbonCommand>
                            </dx:DocumentViewerPrintPageRibbonCommand>
                        </Items>
                    </cc1:DocumentViewerPrintRibbonGroup>
                    <cc1:DocumentViewerExportRibbonGroup>
                        <Items>
                            <dx:DocumentViewerSaveToDiskDropDownRibbonCommand>
                                <Items>
                                    <dx:RibbonPdfFormatCommand>
                                    </dx:RibbonPdfFormatCommand>
                                    <dx:RibbonXlsFormatCommand>
                                    </dx:RibbonXlsFormatCommand>
                                    <dx:RibbonXlsxFormatCommand>
                                    </dx:RibbonXlsxFormatCommand>
                                    <dx:RibbonRtfFormatCommand>
                                    </dx:RibbonRtfFormatCommand>
                                    <dx:RibbonMhtFormatCommand>
                                    </dx:RibbonMhtFormatCommand>
                                    <dx:RibbonHtmlFormatCommand>
                                    </dx:RibbonHtmlFormatCommand>
                                    <dx:RibbonTextFormatCommand>
                                    </dx:RibbonTextFormatCommand>
                                    <dx:RibbonCsvFormatCommand>
                                    </dx:RibbonCsvFormatCommand>
                                    <dx:RibbonPngFormatCommand>
                                    </dx:RibbonPngFormatCommand>
                                </Items>
                            </dx:DocumentViewerSaveToDiskDropDownRibbonCommand>
                            <dx:DocumentViewerSaveToWindowDropDownRibbonCommand>
                                <Items>
                                    <dx:RibbonPdfFormatCommand>
                                    </dx:RibbonPdfFormatCommand>
                                    <dx:RibbonXlsFormatCommand>
                                    </dx:RibbonXlsFormatCommand>
                                    <dx:RibbonXlsxFormatCommand>
                                    </dx:RibbonXlsxFormatCommand>
                                    <dx:RibbonRtfFormatCommand>
                                    </dx:RibbonRtfFormatCommand>
                                    <dx:RibbonMhtFormatCommand>
                                    </dx:RibbonMhtFormatCommand>
                                    <dx:RibbonHtmlFormatCommand>
                                    </dx:RibbonHtmlFormatCommand>
                                    <dx:RibbonTextFormatCommand>
                                    </dx:RibbonTextFormatCommand>
                                    <dx:RibbonCsvFormatCommand>
                                    </dx:RibbonCsvFormatCommand>
                                    <dx:RibbonPngFormatCommand>
                                    </dx:RibbonPngFormatCommand>
                                </Items>
                            </dx:DocumentViewerSaveToWindowDropDownRibbonCommand>
                        </Items>
                    </cc1:DocumentViewerExportRibbonGroup>
                    <cc1:DocumentViewerNavigationRibbonGroup>
                        <Items>
                            <dx:DocumentViewerFirstPageRibbonCommand>
                            </dx:DocumentViewerFirstPageRibbonCommand>
                            <dx:DocumentViewerPreviousPageRibbonCommand>
                            </dx:DocumentViewerPreviousPageRibbonCommand>
                            <dx:DocumentViewerPageNumbersTemplateRibbonCommand>
                                <Template>
                                    <dx:DocumentViewerRibbonCurrentPageLabel runat="server">
                                    </dx:DocumentViewerRibbonCurrentPageLabel>
                                    <dx:DocumentViewerRibbonPagesComboBox runat="server">
                                    </dx:DocumentViewerRibbonPagesComboBox>
                                    <dx:DocumentViewerRibbonPageCountLabel runat="server">
                                    </dx:DocumentViewerRibbonPageCountLabel>
                                </Template>
                            </dx:DocumentViewerPageNumbersTemplateRibbonCommand>
                            <dx:DocumentViewerNextPageRibbonCommand>
                            </dx:DocumentViewerNextPageRibbonCommand>
                            <dx:DocumentViewerLastPageRibbonCommand>
                            </dx:DocumentViewerLastPageRibbonCommand>
                        </Items>
                    </cc1:DocumentViewerNavigationRibbonGroup>
                    <cc1:DocumentViewerReportRibbonGroup>
                        <Items>
                            <dx:DocumentViewerSearchRibbonCommand>
                            </dx:DocumentViewerSearchRibbonCommand>
                            <dx:DocumentViewerParametersPanelToggleCommand>
                            </dx:DocumentViewerParametersPanelToggleCommand>
                            <dx:DocumentViewerDocumentMapToggleCommand>
                            </dx:DocumentViewerDocumentMapToggleCommand>
                        </Items>
                    </cc1:DocumentViewerReportRibbonGroup>
                </Groups>
            </cc1:DocumentViewerHomeRibbonTab>
        </Tabs>
    </dx:ASPxRibbon>

Código C#

Método do evento OnInit="ASPxRibbon1_Init":

///Evento do controle Ribbon
protected void ASPxRibbon1_Init(object sender, EventArgs e)
        {
           
            List<Formato_Arquivo_Grid_BD> oExtensoes = null;

            using (DB_Portal_Transparencia oBD = new DB_Portal_Transparencia())
            {
                oExtensoes = SG_Configuracao_NG.Formato_Arquivo.Pesquisar_Grid(oBD, new Formato_Arquivo_BD());
            }

            if(oExtensoes!=null && oExtensoes.Count > 0)
            {
                foreach (RibbonTab tab in ASPxRibbon1.Tabs)
                {

                    RibbonGroup reportGroup = tab.Groups[1];

                    if (reportGroup == null)
                        continue;

                    RibbonItemBase reportGroup2 = reportGroup.Items[1];

                    foreach (var group2 in reportGroup2.Collection)
                    {
                        if (group2 is DocumentViewerSaveToDiskDropDownRibbonCommand)
                        {
                            DevExpress.XtraReports.Web.DocumentViewerSaveToDiskDropDownRibbonCommand DocumentViewerSaveToDiskDropDownRibbonCommand =
                            group2 as DevExpress.XtraReports.Web.DocumentViewerSaveToDiskDropDownRibbonCommand;

                            foreach (var item in DocumentViewerSaveToDiskDropDownRibbonCommand.Items)
                            {
                                Definir_Visibilidade(item as DocumentViewerRibbonDropDownButtonItemBase, oExtensoes);
                            }
                        }
                        else if (group2 is DocumentViewerSaveToWindowDropDownRibbonCommand)
                        {
                            DevExpress.XtraReports.Web.DocumentViewerSaveToWindowDropDownRibbonCommand DocumentViewerSaveToWindowDropDownRibbonCommand =
                            group2 as DevExpress.XtraReports.Web.DocumentViewerSaveToWindowDropDownRibbonCommand;

                            foreach (var item in DocumentViewerSaveToWindowDropDownRibbonCommand.Items)
                            {
                                Definir_Visibilidade(item as DocumentViewerRibbonDropDownButtonItemBase, oExtensoes);
                            }
                        }
                    }
                }
                //var showParametersPanelCommand = (RibbonToggleButtonItem)reportGroup.Items.FindByName("ShowParametersPanelToggleCommand");
                //var showDocumentMapCommand = (RibbonToggleButtonItem)reportGroup.Items.FindByName("ShowDocumentMapToggleCommand");
                
            }
        }

///método que consulta a lista do banco e define a visibilidade do botão de exportação.
private DocumentViewerRibbonDropDownButtonItemBase Definir_Visibilidade(DocumentViewerRibbonDropDownButtonItemBase pItem, List<Formato_Arquivo_Grid_BD> pExtensoes)
        {
            DocumentViewerRibbonDropDownButtonItemBase obj = null;

            switch (pItem.GetType().Name)
            {
                case "RibbonPdfFormatCommand":
                    obj = pItem as RibbonPdfFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "PDF" && c.Exibir == true);
                 break;
                case "RibbonXlsFormatCommand":
                    obj = pItem as RibbonXlsFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "XLS" && c.Exibir == true);
                    break;
                case "RibbonXlsxFormatCommand":
                    obj = pItem as RibbonXlsxFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "XLSX" && c.Exibir == true);
                    break;
                case "RibbonRtfFormatCommand":
                    obj = pItem as RibbonRtfFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "RTF" && c.Exibir == true);
                    break;
                case "RibbonMhtFormatCommand":
                    obj = pItem as RibbonMhtFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "MHT" && c.Exibir == true);
                    break;
                case "RibbonHtmlFormatCommand":
                    obj = pItem as RibbonHtmlFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "HTML" && c.Exibir == true);
                    break;
                case "RibbonTextFormatCommand":
                    obj = pItem as RibbonTextFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "TEXT" && c.Exibir == true);
                    break;
                case "RibbonCsvFormatCommand":
                    obj = pItem as RibbonCsvFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "CSV" && c.Exibir == true);
                    break;
                case "RibbonPngFormatCommand":
                    obj = pItem as RibbonPngFormatCommand;
                    obj.Visible = pExtensoes.Exists(c => c.Sigla.ToUpper() == "IMAGE" && c.Exibir == true);
                    break;
                default:
                    break;
            }

            return obj;           
        }

Comentários

Postagens mais visitadas deste blog

EmguCV DLL Not Found Exception -Unable to find cvextern?

Eu também tive os mesmos problemas. Neste fórum emgucv , não sei por que cvextern.dlldo emgucv 3.4.3 não é possível carregar cvextern (porque não é possível encontrar cvextern), e você permitiu usar o arquivo cvextern.dlldo emgucv 3.4.2 (certifique-se de escolher x64 / x86), copie /bin/Debuge este arquivo é encontrado automaticamente /bin/Debug/x86ou /bin/Debug/x64quando você termina de construir o programa no Visual Studio.  O Erro:  The type initializer for 'Emgu.CV.CvInvoke' threw an exception. : Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)  Para resolver o problema copia a pasta x64 ou x86 para dentro da pasta bin da aplicação. Ou copie os arquivos para dentro da pasta bin da aplicação WCF.

Vagas .Net - Projeto CNSA

Prezados, Estamos selecionando candidados, em forma de cadastro de reserva, para participar do projeto: Cadastro Nacional de Sociedade de Advogados, na Assessoria de Tecnologia da Informação do Conselho Federal da OAB. Basicamente teremos 3 fases: * Avaliação Curricular; * Entrevista Pessoal; * Verificação prática; Outras informações: Vaga: Desenvolvedor .NET. Quantidade: 3. Tempo: 4 meses. Segue abaixo os requisitos que devem ser atendidos pelo candidato: Conhecimentos básicos * Conhecimento avançado em C#; * Conhecimento em ASP.NET 2.0; * ADO.NET 2.0; * SQL SERVER 2005 (DML, stored procedures, MER); * UML (Interpretação de casos de uso, diagrama de atividades, de classe, de sequência); * Experiência em projetos anteriores com ASP.NET e C#; Desejável * LINQ TO SQL; * Conhecimento em JavaScript e padrões Web (XHTML, CSS, etc); * ASP.NET 3.5; * C# 3.0 (LINQ, Propriedade implementadas automaticamente, Métodos de Extensão, Expressão Lamb...

Lista de IPs DNS Oi nos Estados

As vezes quando colocamos um IP fixo para uma máquina na rede, e esta rede tem acesso a internet através da rede da Oi, bem provável que você não conseguirá acessar a internet. Para resolver o problema defina o DNS primário e Secundário nas propriedades da placa de rede. - Protocolo TCP/IP Versão 4 (TCP/IPv4). Segue lista de DNS por estado. RS 201.10.1.2 201.10.120.3 SC 201.10.120.3 201.10.1.2 PR 201.10.120.2 201.10.128.3 GO 201.10.128.3 201.10.120.3 DF 201.10.128.2 201.10.120.2 MS 201.10.128.3 201.10.1.2 MT 201.10.128.2 201.10.120.3 RO/AC 201.10.128.2 201.10.1.2