Events in basic layouts objects

Objective

There are many cases in which the developer needs to adapt the default K2BTools User Interface in order to create another User Interface that satisfies its users’ needs. K2BTools provides all the flexibility in Basic Layouts to do that. Not only the layout objects allows the developer to arrange where the controls will be placed, but also it allows them to add code that will be added to all objects that are generated using this Basic Layout.

This page explains how to add event code to basic layouts.

How it works

All basic layout objects have a property called “Has Events Code”.

BasicLayoutHasEventsCode property
"Has Events Code" property

If this property is set to “true”, when applying the patterns or designer, all code located in the basic layout events will be added to the generated objects.

For code placed in events generated by K2BTools (ex: start, refresh, event), the code will be added before K2BTools code.

For code placed in events that are not generated by K2BTools, the events will be added after all events code generated by K2BTools.

Conditional code

There are some scenarios, when the developer needs that the code will be added only if certains conditions apply. For example, add these lines of code only if there are filters. For this purpose in the Basic Layouts the developer have the possibility to place some code in a slot and this slot will be generated only if the conditions apply.
So if the developer add code to an slot with the name “If.Filters” the code will be generated only if the grid has filters.

//+ If.Filters

BasicLayoutIfFilterCode
The code will only be generated if the grid has filters.

Currently, the only conditional code slot is “//+ If.Filters”.
If you need other conditional slots, please contact K2BTools support team (support@k2btools.com)