Configure Tab Navigation To Optimize Performance
You can use tab navigation to improve user experience when a form is loaded. For example you can use actions to open, load and refresh a view 'on-demand'; instead of loading a view when the form initializes, only load the view if the form user specifically clicks a tab. This can help to improve form performance by delaying loading data until the form user wants to see the data. You can use the Load, Initialize and List refresh methods when the tab is opened instead of when the form initializes, to minimize the delay time when a form opens.
You can also use this method in conjunction with the collapse and expand view events and actions to enhance performance even more by collapsing certain views and only loading their data when the view is expanded. See Configure the Collapse And Expand View Events And Actions for information about configuring these events and actions.
When you add views to a form, rules are automatically created to initialize and refresh the views when the form initializes. If your form contains
Depending on your scenario and rule configuration, you can also use the go to a tab action and combine it with a when a button is clicked event. This means that you can move the view initialize and refresh methods to execute when a button is clicked and a tab opens.
In this example, you have a form containing Client and Region tabs. The Client tab contains a Client Item view and Client List view, and the Region tab contains a Region Editable List view. When you generate a form using multiple views, K2 automatically creates a default rule called When the Form is Initializing, which executes the Initialize and List refresh methods for all views when the form opens. The image below shows the default Initializing rule for this example.
Default rule configuration
To improve the user experience and speed up the load time of the form, you can move the Initialize and List refresh actions of the Region Editable List view to a rule which only executes when the Region tab is clicked. This allows you to execute these actions when a tab is clicked. The images below show what the enhanced configuration looks like.
Enhanced rule configuration showing the Initializing event excluding the actions for the Region Editable List view
Enhanced rule configuration showing the tab click event containing the Initialize and List refresh methods of the Region Editable List view
Essentially, the rules are as follows:
- The form loads with the (Initializing) event.
- The Client List view loads.
- The Client Item view loads.
- The Client List view refreshes.
- When you click the Region tab, the Region Editable List view loads.
- The Region Editable List view refreshes.
Follow the steps below to configure the rule shown above.
- Edit the When the Form is Initializing rule, select then on Region Editable List View, execute the Initialize method and click Remove or the click the Remove icon as shown below. Do the same for the then on Region Editable List View, execute the List refresh method action and then click OK to save the rule.
- Click Add Rule to add a rule when the Region tab is clicked.
- In the Events tab, click the When a control on the Form raises an event event in the Form Events section, and then select the Region as the control and Clicked as the event as shown below.
- Add the Initialize method that you removed from the default form Initialize rule. Go to the Actions tab, click the Execute a View method action in the SmartObject Interaction section, and then select the Region Editable List as the view and Initialize as the method as shown below.
- Click Execute a View method again to add the List refresh action that you removed from the default form Initialize rule, and then select the Region Editable List as the view and List refresh as the method as shown below. Click OK to save the rule. The Region Editable List view now opens and refreshes when the Region tab is clicked instead of when the form opens.
- Save and finish the view, and then run the form to test that the Region Editable List view loads when you click the Region tab.
This example improves performance because the Region Editable List view only loads data when you click the Region tab. When you use tab navigation to reconfigure the view initialize and refresh actions, remember to delete or disable those actions from the form initialize rule.