Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote Source for list fields doesn't appear to work as at latest versions #2352

Open
markusdf opened this issue Dec 15, 2022 · 5 comments
Open

Comments

@markusdf
Copy link

as per the demo page https://w2ui.com/web/demos/#/fields/6

the url property for list and multi list fields does not appear to work.

the demo page does not work, attempting to follow the documentation also appears to not work. On the demo page the request and load events should be logging to console, however there is nothing.

attempting to create remote data list boxes in forms also appears to have the same issue of the url property being ignored.

@markusdf markusdf changed the title Remote Source for Fields doesn't appear to work as at latest versions Remote Source for list fields doesn't appear to work as at latest versions Dec 15, 2022
@ratones
Copy link

ratones commented Jan 19, 2023

Looking at the code I see a lot of differences on how the search is implemented in lists and combo. The search is delegated to the tooltip menu, so it's not that easy to refactor.
I really needed this functionality so i went ahead and write some code. I added an event in the menu that is triggered on keyUp if the url is present. The w2field listens to this event alongside the listener for the select event, in updateOverlay method and if the url is specified i go ahead and get the data from server. When the data arrives I just call the update method on the menu with the new items. While the request is loading I called lock method on the menu box, to show the spinner After update i had to set the activeChain property of the menu to null and call refreshSearch and refreshIndex methods.
It kind of works now, but not tested enough.
If anyone cares about this solution please leave a comment here and I will post my solution.

@LysOffice
Copy link

interresting !

@LysOffice
Copy link

Hello again ,
I add this event code , but i need to refresh the list after changing items , any ideas ?

query('#field1')
.on('keyup', (event) =>  {
        let sel = fld1.get()
		fetch('https://apis.******/v1/***/'+sel)
		.then(response => response.json())
		.then(response => fld1.options.items = response.records)	
		//how to refresh the list ?
    })

@markusdf
Copy link
Author

according to the docs, you should be able to use the render function of the form to do it, but for me, this only works once. Once there's some data in the list, triggering it a second time doesn't work, which isn't ideal.

@markusdf
Copy link
Author

markusdf commented Apr 21, 2023

Hello again , I add this event code , but i need to refresh the list after changing items , any ideas ?

query('#field1')
.on('keyup', (event) =>  {
        let sel = fld1.get()
		fetch('https://apis.******/v1/***/'+sel)
		.then(response => response.json())
		.then(response => fld1.options.items = response.records)	
		//how to refresh the list ?
    })

did you ever get this working? I've had zero luck trying to refresh the listbox contents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants