Setting first item in listview selected when opening a page
2
I want the first item in a listview to be selected, because a dataview is listening (Listen to widget) to this listview and I want the user to have visual feedback when opening a page that indeed the first item is active. Similar as https://community.mendix.com/link/questions/88441 The suggestion in that other post hints at using a Javascript snippet. So I thought I would use that approach, but it's not working for me. This is what I have on my page: And I have the following in the HTMLSnippet: document.getElementsByClassName("master-detail-masterlist")[0].getElementsByClassName("mx-listview-item")[0].className += " selected"; I tried a few things, but I get the following on my page: Any suggestions?
asked
Tim Misker
2 answers
3
Fixed in 7.22!
answered
Tim Misker
2
Hi Tim,
IOP it is a bad idea to use javascript to manipulate mendix widgets. There are timing issues to consider and also there is no guarantee that mendix will not change the behavior in a future release. If you really have to have the first element selected, then I suggest you wrap the page in a container object with a "selected" association and use some conditional visibility to set some styling so that it looks like a selected item.