In mendixmodelsdk, how to find a widget , use the common name?

0
Hello everyone, App is committed to the server. Use mendixmodelsdk, I want to bind a nanoflow to the textbox/button, which only knows its name. Any advice or suggestion would be nice. const pageinterface = this.workingCopy.model().allPages().filter(page => page.name === "mypagename")[0]; const page = when.promise((resolve, reject) => loadable.load(resolve)); // I can find the widget like this:(It's so clumsy) const textbox = page.layoutCall.arguments[0].widgets[0].rows[0].columns[0].widgets[0].widgets.filter(widget => widget.name === "txtCtrlSystemId')[0]; const button = page.layoutCall.arguments[0].widgets[0].rows[0].columns[0].widgets[0].footerWidgets[0].rows[0].columns[1].widgets.filter(widget => widget.name === "btnSave")[0]; //Does modelSdk have methord like this: page.findElementByName("txtCtrlSystemId")??? Does modelSdk have methord like this: find...By...Name("txtCtrlSystemId")?
asked
1 answers
2

You can use traverseFind on the page to search for elements. Since not all elements have a name, there is no default API for it.

It would look something like this:

const button = page.traverseFind(structure => structure instanceof pages.Widget && structure.name === "txtCtrlSystemId");

Good luck :).

answered