Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
8920
wdd custom values stay when pasted.
posted

WDD  2 questions 

  1. When wdd configured with enabling custom values/selection as false.. User can not type in values that are not in the drop down.. In the supplied sample if I highlight  contents and try to type e.g. 44444 it is not going to let me.. Which is good.. The issue if I do the same, highlight the contents and instead of typing copy 444444 from any open document and then paste it into the text box of the control .. it stays there.. Now if I post it, wddle.SelectedValue  will be the previously selected value.. The question is how to prevent capability to paste custom values into the control because it leads to user’s confusion …

         2. If there is a way to configure wdd so it will display x in the text box that will allow mouse click to clear it instead of highlighting              and deleting.. 

WDD.zip

Parents
  • 1300
    Verified Answer
    Offline posted

    Hello Michael,

    After investigating this further, I determined that your requirement could be achieved by binding a method to the ValueChanging event. In this method it is checked whether any of the items starts with the pasted value, if no, the event is canceled. Otherwise, the new item is selected:

    function paste(sender, args) {          

                var itemContains = false;

                for (let i = 0; i < sender.get_items().get_length(); i++) {

                    var itemVal = sender.get_items().get_item(i).get_element().textContent;

                    if (!sender._currentEvent || itemVal.startsWith(sender._currentEvent.target.value))

                        itemContains = true;

                }

                if (!itemContains)

                    args._cancel = true;

            }

    Regarding setting clear icon in the input field of the WebDropDown, a method is bound to the Initialize and ValueChanged event, where an image is appended to the input. On click of this image the selected item is unselected and the value of the input is cleared.

    function setButton(sender, args) {

                var deleteButton = $(document.getElementById("del"))[0];

     

                sender._element.childNodes[1].childNodes[2].childNodes[1].childNodes[1].childNodes[1].style = "display:flex; width:300px";

                sender._element.childNodes[1].childNodes[2].childNodes[1].childNodes[1].childNodes[1].appendChild(deleteButton);

            }

    Below I am attaching a sample, demonstrating the described behavior. Please test it on your side and let me know if you need any further information regarding this matter.

    Regards,
    Monika Kirkova,
    Infragistics

    WebDropDownPasteValue.zip

Reply Children
No Data