data-setup
The data-setup attribute is the declarative initialization hook used by Tripous components.
It lets server-rendered or static markup carry the same options that could otherwise be passed from JavaScript
to a component constructor. When a tp.Component creates or wraps its handle, it reads the
data-setup object, merges it into the component create params, and then calls the component
ApplyCreateParams() method.
The value is a JavaScript object literal, not strict JSON. Property names may be unquoted and strings may use single quotes. This is intentional because Razor-generated markup can use compact object-literal syntax. The attribute is read during component construction; changing the attribute later does not reconfigure an existing component. To change a control after construction, use its public properties.
A property has effect only when the component explicitly supports it. Common base properties such as
Text, ToolTip, CssClasses, and TabIndex are handled by
tp.Component. Control-specific properties such as Decimals, SelectedValue,
Date, Placeholder, or ImageUrl are handled by the concrete class.
This keeps initialization predictable and avoids a generic "assign anything" rule.
For a more advanced example, see the tp.CtrlRow demo. It shows how
data-setup can initialize a row label and a nested control declaration in the same markup.
TextBox
Base text and input-specific options are applied before the first render.
NumberBox
The text box is configured as a numeric control with decimal formatting.
ComboBox
Object lists can be declared inline when the markup owns the list.
DateBox
Date text is parsed through the same date helper used by the control.
TreeView
Nested markup can combine root setup and per-node setup.
<input id="DataSetupTextBox"
type="text"
data-setup="{ Text: 'TripousJS',
Placeholder: 'project name',
MaxLength: 40,
ToolTip: 'Initialized by data-setup' }" />
<input id="DataSetupNumberBox"
type="text"
data-setup="{ Value: 1234.5,
Decimals: 2,
Placeholder: 'amount' }" />
<div id="DataSetupComboBox"
data-setup="{ ListOnly: true,
ListValueField: 'Id',
ListDisplayField: 'Name',
SelectedValue: 'GR',
List: [
{ Id: 'GR', Name: 'Greece' },
{ Id: 'CY', Name: 'Cyprus' },
{ Id: 'IT', Name: 'Italy' }
] }"></div>
<div id="DataSetupDateBox"
data-setup="{ Date: '4/1',
Placeholder: 'date',
TextAlign: 'right' }"></div>
<div id="DataSetupTreeView" data-setup="{ Expanded: true }">
<div data-setup="{ ImageUrl: '../tripous/images/demos/Home.png',
ToolTip: 'Home node' }">
Home
<div>Dashboard</div>
<div>Reports</div>
</div>
<div data-setup="{ Url: 'https://w3c.github.io/html/dom.html',
ToolTip: 'Opens in a new browser tab' }">
HTML DOM reference
</div>
</div>