0 votes

We found a flaw in build 6640, due to a remark of a customer after migration.

This Is according to a lookup in a category with the Edit style: Lookup-up with search window (this lookup has more than 1500 records).

In a category it wants to use the data-msg="pickListSearch;….” but this function doesn’t exists in the build.
So it looks like we didn’t migrate this function, because it’s only present in the efficy.dll.

I ask this because I think it is a high urgency case, the customer uses this dropdowns in multiple ways.
Because the lookup has 1500 records there is no work-around.

Anybody has a solution for this?

Regards,

Michael de Groot

asked in Efficy/ Client side by (188 points)

1 Answer

0 votes

Hello Michael,

First, i think "picklistSearch" is not exist, there's only "picklist". did you try to change it to picklist only?
And i did something similar for a list containing around 1900 values more or less.
first on MacroEditSCustom, i used funciton AfterLoaded to change the data-msg value to call a custom function, like this:

function AfterLoaded(){ 
        if($('#CATEGORY-COMP$CUSTOMERS-R_F_ACTIVITY')){
            //aal: data-msg should be replaced on both the list and the small arrow on the right (user can click on any of them)
            var dataMsg1 = $('#CATEGORY-COMP$CUSTOMERS-R_F_ACTIVITY').attr('data-msg').toString();
            var dataMsg2 = $('#B_F_ACTIVITY').attr('data-msg').toString();
            dataMsg1 = dataMsg1.replace("pickList", "pickListCustom");
            dataMsg2 = dataMsg2.replace("pickList", "pickListCustom");
            $('#CATEGORY-COMP$CUSTOMERS-R_F_ACTIVITY').attr('data-msg', dataMsg1);
            $('#B_F_ACTIVITY').attr('data-msg', dataMsg2);
        }
}

then define "pickListCustom" in editdetailsCmd.js:

function pickListCustom(field, namePrefix){
        var
            useValue = Model('entity') === 'Qrvw' || Model('entity') === 'Quer',
            url = format('dialog?page=DialogDropdownSearchActivity&edithandle={editHandle}&name=$0&lookup=$1$0&useValue=$2', field, namePrefix, useValue),
            target = document.getElementById(namePrefix + 'R_' + field) || document.getElementById(namePrefix + field);
        Foundation.libs.dropdown.open($('#dd-dropdown-host'), $(target), {url: url}); // TRW, use dd ajax container
    }

then in pages, i created new page with name "DialogDropdownSearchActivity" with following script. just few notes to consider, first set the count in GetLookupList to big number like in my case 2000 so all values are in the list. Second the function "filterByText" is off-the-shelf i just found it on internet, it works perfectly. Also funciton "addEvent" is found in Efficy.js, i just put it in the code to use it directly. Basically you need to care for DivLoaded and PostValue function and change the fields id according to your case:

<%SetBookmark()%>
<%GetLabel("Search")%> :&nbsp;<input id="FQuery"><br>
<select id="FSelect" size="12"><%GetLookupList(count="2000")%></select>
<script>
//AAL: "filterByText" is function off-the-shelf (found on internet) for filtering select dropdown from search box
jQuery.fn.filterByText = function(textbox, selectSingleMatch) {
    return this.each(function() {
        var select = this;
        var options = [];
        $(select).find('option').each(function() {
            options.push({value: $(this).val(), text: $(this).text(), disabled:$(this).is(':disabled')});
        });
        $(select).data('options', options);
        $(textbox).bind('change keyup', function() {
            var options = $(select).empty().scrollTop(0).data('options');
            var search = $.trim($(this).val());
            var regex = new RegExp(search,'gi');

            $.each(options, function(i) {
                var option = options[i];
                if(option.text.match(regex) !== null) {
                    var newOption = $('<option>');
                    if(option.disabled) {
                        newOption.attr('disabled', 'disabled');
                    }
                    newOption.text(option.text).val(option.value);
                    $(select).append(newOption);
                }
            });
            if (selectSingleMatch === true &&
                $(select).children().length === 1) {
                $(select).children().get(0).selected = true;
            }
        });
    });
};

    var SelectList;
    var LastSearchValue = "";
    var DropDownInput = document.getElementById('CATEGORY-COMP$CUSTOMERS-R_F_ACTIVITY');
    var DropDownInputHidden = document.getElementById('CATEGORY-COMP$CUSTOMERS-F_ACTIVITY');
    //crossbrowser add event function
    function addEvent(elm, evType, fn, useCapture)
    {
        if (elm.addEventListener){
            elm.addEventListener(evType, fn, useCapture);
            return true;
        } else if (elm.attachEvent){
            var r = elm.attachEvent("on"+evType, fn);
            return r;
        } else {
            alert("Please upgrade your browser to use full functionality on this page");
        }
    }

    function DivLoaded() {
        $('#FSelect').filterByText($('#FQuery'), false);
        SelectList = document.getElementById("FSelect");
        addEvent(SelectList, 'click', PostValue, false);
        // e.stop(), prevent submitting the whole form on 'enter'
        addEvent(SelectList, 'keypress', function(e){if(['space','enter','tab'].contains(e.key)) {   e.stop(); PostValue(); }}, false);
        document.getElementById("FQuery").focus()
    }

    function PostValue() {
    requirejs(
        ['jquery', 'utils/format', 'foundation.dropdown'],
        function ($, format) {
            if (SelectList.options.length == 0) return
            var SelectedOption = SelectList.options[SelectList.selectedIndex]
            DropDownInput.value = SelectedOption.text;
            DropDownInputHidden.value = SelectedOption.value;
            DropDownInput.focus();
            EntitySetModified();    
        });
    }

    DivLoaded();

</script>

I hope this helps or gives a clue ;)

Best Regards.

answered by (559 points)
1,169 questions
1,426 answers
1,717 comments
325 users