Forum Discussion

detroit's avatar
detroit
Creator I
7 years ago
Solved

How can you open search dialog in javascript with a filter

Hello

as per title - how can we set the filter for search dialog in javascript

var param = {
                title: title,
                aras: top.aras,
                type: 'SearchDialog',
                dialogWidth: 700,
                dialogHeight: 450,
                itemtypeName: 'Part'            
            };
wnd.ArasModules.Dialog.show('iframe', param).show("iframe", param);
Is it possible to catch an even of this dialog?
Or how can we manually run the opened dialog "search"? The dialog is an iframe and the dijits have no ids 
I managed to make it work for test case with, mind you i cannot use this in reality, scope issues
 dijit.byId("dijit_form_TextBox_0").setDisplayedValue("3*");
 dijit.byId(dojo.query('.dijitButton')[0].attributes.widgetid.nodeValue).onClick()
Thank you
  • Hello,

    For this use case, we typically recommend creating a new property on the ItemType to serve as a placeholder to attach your onSearchDialog event to. This will new property is typically not intended to store any data and should be hidden from every form and grid. You can call this property something like filter_placeholder.

    Once you have this new property on the Part ItemType, you can attach your onSearchDialog to it and update your method code to use this new property's name to call the filtering event.

    var param = {
                    title: title,
                    aras: top.aras,
                    type: 'SearchDialog',
                    dialogWidth: 700,
                    dialogHeight: 450,
                    itemtypeName: 'Part',
                    
                    sourceItemTypeName: 'Part',
                    sourcePropertyName: 'filter_placeholder'
                };
    var dialog = wnd.ArasModules.Dialog.show('iframe'param);
    dialog.promise.then(dojo.partial(callbackcopy));

    Chris

    Christopher Gillis

    Aras Labs Software Engineer

14 Replies

  • Hello,

    It is possible to filter a search dialog by setting an onSearchDialog event on a property of an ItemType as outlined in this blog.

    When calling a search dialog from JavaScript like in your example, you can set the sourceItemTypeName and sourcePropertyName in the parameters you pass in. If an onSearchDialog event exists on the property name you pass in using these parameters, that filter will be applied to the search dialog opened by your code. For a full list of the parameters available when opening a search dialog, please see this blog post on using standard aras dialogs.

    Chris

    Christopher Gillis

    Aras Labs Software Engineer

    • detroit's avatar
      detroit
      Creator I

      Hello Christopher, I've met with this article before but i was rather certain it involved custom search dialog, maybe im wrong? I will read this article thoroughly in hopes of understanding it and come back with more questions probably. Thank you for now.

    • detroit's avatar
      detroit
      Creator I

      Hello again Christopher, my code is below could you help me understand what i could bind the onSearchDialog event to? Dialog itself contains just a promise and dom element of dialog. And i tried to connect to the event on the node itself (but it obviously doesnt emit it)

      var param = {
                      title: title,
                      aras: top.aras,
                      type: 'SearchDialog',
                      dialogWidth: 700,
                      dialogHeight: 450,
                      itemtypeName: 'Part',
                      
                      sourceItemTypeName: 'Part',
                      sourcePropertyName: '*3'
                  };
        var dialog = wnd.ArasModules.Dialog.show('iframe', param);
        dialog.promise.then(dojo.partial(callback, copy))
      • christopher_gillis's avatar
        christopher_gillis
        Community Manager

        Hello,

        For this use case, we typically recommend creating a new property on the ItemType to serve as a placeholder to attach your onSearchDialog event to. This will new property is typically not intended to store any data and should be hidden from every form and grid. You can call this property something like filter_placeholder.

        Once you have this new property on the Part ItemType, you can attach your onSearchDialog to it and update your method code to use this new property's name to call the filtering event.

        var param = {
                        title: title,
                        aras: top.aras,
                        type: 'SearchDialog',
                        dialogWidth: 700,
                        dialogHeight: 450,
                        itemtypeName: 'Part',
                        
                        sourceItemTypeName: 'Part',
                        sourcePropertyName: 'filter_placeholder'
                    };
        var dialog = wnd.ArasModules.Dialog.show('iframe'param);
        dialog.promise.then(dojo.partial(callbackcopy));

        Chris

        Christopher Gillis

        Aras Labs Software Engineer