# Find concepts if forms are dynamically loaded

**URL:** <https://forum.servoy.com/t/find-concepts-if-forms-are-dynamically-loaded/8935>\
**Category:** Classic Servoy\
**Created:** [March 27, 2008, 1:56pm UTC](https://forum.servoy.com/t/find-concepts-if-forms-are-dynamically-loaded/8935 "2008-03-27T13:56:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [March 27, 2008, 1:56pm UTC](https://forum.servoy.com/t/find-concepts-if-forms-are-dynamically-loaded/8935/1 "2008-03-27T13:56:16Z")

</div>

Hello Servoyans

Having a main form where we dynamically load forms into (according to a selected menu), I am wondering what concepts are in use to get Find to work?  
I can’t seem to find examples on what concepts developers get Find/Search to work when the forms are dynamically loaded (and the solution has modules).

Any help, ideas? How do you do it?

Best regards, Robert

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [March 27, 2008, 3:38pm UTC](https://forum.servoy.com/t/find-concepts-if-forms-are-dynamically-loaded/8935/2 "2008-03-27T15:38:25Z")

</div>

I’m not sure to understand exactly what you mean but I think that this could get you on the right track:

```auto
var current_form = elements.tab_main.getTabFormNameAt(elements.tab_main.tabIndex)
forms[current_form].controller.find()

```

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [March 27, 2008, 4:10pm UTC](https://forum.servoy.com/t/find-concepts-if-forms-are-dynamically-loaded/8935/3 "2008-03-27T16:10:36Z")

</div>

Hello Nicola

I also tried in my experiments what you suggest and the form is (or at least seems to be) going into find mode. I also attached to the same main form the onSearchCmd method which basically contains the line

forms[current\_form].controller.search()

But the onSearchCmd method is NOT triggered on pressing return in a field or pressing F3. I am not able to trigger the onSearchCmd method. Is your onSearchCmd triggered?

The onFindCmd on the same form works, though. Very strange.

Thanks and regards, Robert

PS: The main form contains tabless panels, and they get loaded like shown in the code excerpt below:

…  
var menuId = forms.DomMenu.getSelectedMenuId();

initializeJSplitPane();  
elements.tabSelection.removeAllTabs();  
elements.tabDetail.removeAllTabs();

switch(menuId)  
{  
case 101:  
elements.tabSelection.addTab(forms.StnStations, null, null, null, null,‘#000000’,‘#BBCCEE’);  
elements.tabDetail.addTab(forms.StnStationAndMasterData, null, null, null, null,‘#000000’,‘#BBCCEE’);  
break;

case 102:  
elements.tabSelection.addTab(forms.StnStations, null, null, null, null,‘#000000’,‘#BBCCEE’);  
elements.tabDetail.addTab(forms.StnStationAndProperties, null, null, null, null,‘#000000’,‘#BBCCEE’);  
break;

case 103:  
elements.tabSelection.addTab(forms.StnStations, null, null, null, null,‘#000000’,‘#BBCCEE’);  
elements.tabDetail.addTab(forms.StnStationAndTimetable, null, null, null, null,‘#000000’,‘#BBCCEE’);  
break;  
…

> ngervasi:  
> I’m not sure to understand exactly what you mean but I think that this could get you on the right track:
> 
> ```auto
> var current_form = elements.tab_main.getTabFormNameAt(elements.tab_main.tabIndex)
> 
> ```

forms[current\_form].controller.find()

> ```auto
> 
> ```

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [March 27, 2008, 4:39pm UTC](https://forum.servoy.com/t/find-concepts-if-forms-are-dynamically-loaded/8935/4 "2008-03-27T16:39:35Z")

</div>

> Robert Huber:  
> I also attached to the same main form the onSearchCmd method which basically contains the line
> 
> forms[current\_form].controller.search()
> 
> But the onSearchCmd method is NOT triggered on pressing return in a field or pressing F3. I am not able to trigger the onSearchCmd method. Is your onSearchCmd triggered?

You must attach the method to perform the search to the form that actually goes into find mode, not to the main form, if you want to be able to start the search by hitting return or F3.

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [March 27, 2008, 5:28pm UTC](https://forum.servoy.com/t/find-concepts-if-forms-are-dynamically-loaded/8935/5 "2008-03-27T17:28:57Z")

</div>

> ngervasi:
> 
> > Robert Huber:  
> > I also attached to the same main form the onSearchCmd method which basically contains the line
> > 
> > forms[current\_form].controller.search()
> > 
> > But the onSearchCmd method is NOT triggered on pressing return in a field or pressing F3. I am not able to trigger the onSearchCmd method. Is your onSearchCmd triggered?
> 
> You must attach the method to perform the search to the form that actually goes into find mode, not to the main form, if you want to be able to start the search by hitting return or F3.

I also tried that, but unfortunatly that doesn’t work either, i. e. the onSearchCmd method is still not fired, even if I attach the onSearchCmd method to the onSearchCmd hook on the form which is set into find mode. Does that really work in your solution?

Thanks, Robert
