0 votes

Hello,

I'm trying to copy the behavior on document grid for attachment (to show atatchment as popup and open them)
enter image description here

I added the following text in grid/queryResult.htm, but the popup is not showing and no error on browser's console

<#FDEF=ATTACHMENTS><td class="icon-cell i-attach pointer" data-dropdown="dd-files" data-options="align:left" data-dropdown-ajax="consult?page=dropdown/Files.htm&count=-1&filter=false&detail=File&sort=K_SORT&entity=Docu&key=<#F=K_DOCUMENT>"><#F=FIELDNAME></td></#FDEF>

Please help and advise if it's possible. Thank you for your help in advance.
Best Regards.

asked in Efficy/ Client side by (559 points)

1 Answer

0 votes
Best answer

This is how I would do it :

forget about query,
use a report.

Create a new HTML report and configure it like this :

enter image description here

This is what contains the html page of my report (as an example) in custom/smycustom/pages/reports/testDatagrid.htm

<%SetBookmark()%>
<%LoadMacros('MacroLibrary;MacroDialog;MacroGridtools')%>
<%Macro('Doctype')%>
<html lang="<%GetLanguage(lowercase=T)%>" dir="<%OnLanguage(ar='rtl', else='ltr')%>">
<head>
    <title><%GetLabel('My HTML report')%></title>
    <%UseStyleSheet(page='%%OnLanguage(ar="efficy-rtl", else="efficy")')%>
    <%UseScript("../lib/js/vendor/modernizr.js", fixedline=T, fixedpath=T)%>
    <script>
        function Loaded() {
            requirejs(['jquery', 'commandPublisher', 'misc/grid', 'foundation.dropdown'], function ($, CommandPublisher, Grid) {
                $(document).foundation('dropdown');
                CommandPublisher.start();
                Grid.start();
            });
            <%Macro('DialogModel')%>
        }
        function Perform(Result, Label) {
            <%GetDialogAction()%>
        }
    </script>
</head>
<body onload="Loaded()" data-keep-size>
    <%RunQuery(
        id="myquerry",   mainquery="true",
        sql="select top 30 * from admin.R_DOCUMENTS"
    )%>
    <div class="row dialog-wrapper">
        <div class="small-12 columns">
            <section class="form">
                <h3 class="section-title"><%GetLabel('Select Template')%></h3>
                <div class="row collapse">
                    <div class="small-12 columns">
                        <ul id="cmd-grid-menu" class="button-group toolbar small grid" data-channel="entitylist/tools">
                            <%Delay(1)%>Macro('GridCommandsBasic', $context$='D')%>
                        </ul>
                    </div>
                </div>
                <%GetDialogGrid(query="myquerry", columndefs="GridColumns.txt", 
            entity="Docu",
            columns="NAME,K_DOCUMENT,ATTACHMENTS{FILE}"
        )%>
        </section>
        </div>
    </div>
<!--</body>-->
<%Macro('DialogScripts')%>
</body>
</html>

and this is my result :

enter image description here

does this answer your problem? (plus you can use group functions and filter and even sums^^.

answered by (986 points)
selected by
Just an important info the module that is suppose to catch your msg here is not started because the report use a dialog context. but you can freely start the module js that catch the consult messagee
Hello Louis,

That works perfectly as alternative, thank you for help.

I'm just curious about your note to startup the module that catch consult message, isn't that main/consult? how to start it in dialog context?

Best Regards
just change the Loaded function with this and it will work :

    function Loaded() {
            requirejs(['jquery', 'commandPublisher', 'misc/grid', 'foundation.dropdown', 'commands/filehelperCmd', 'filehelper'], function ($, CommandPublisher, Grid, FilehelperCmd, Filehelper) {
                $(document).foundation('dropdown');
                CommandPublisher.start();
                Filehelper.start();
                Grid.start();
                console.log("Loaded");
            });
            <%Macro('DialogModel')%>
        }
Hello Louis,

Indeed, now it works, but when i click the button to download the file,it's downloaded twice, any ideas?
Thank you.
Best Regards.
since the report is loaded in an iframe and since you don't want all your dialog overided you can just use requirejs to load the modules needed and then to start them :

i ve checked the code and
filehelperCmd contains the command "open", since it s just a commands module you don't have to start it and it will subscribe to the "files" channel
filehelper is the module that contains the open fonction. this module needs to be started. by starting it you can set a lot of options.
this only work because you alreday start the commandPublisher module of course.

the point is that in the attachement popup menu the data-channel is specified to "files" so you don't have to create the data-channel yourself.

then when you will clic on the attachement the msg open will be publish on the channel "files" with a parameter identifying the attachement.
your module filehelperCmd will catch it and call the open fonction of the filehelper module started in the loaded function, the parameter will of course be passed.

and Voila (to quote Stéphane Roncin)
I guess that for some reason the filehelper module is started twice.... mmmmh i cant reproduce this behaviour it works for me...
which build do you use?
1,226 questions
1,495 answers
1,831 comments
328 users