This repository has been archived by the owner on Dec 3, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Use JavaScript with Tag Helpers (Event Handlers, Templates, etc)
Aleksey Martynov edited this page Jun 30, 2016
·
1 revision
To handle client-side events, specify DOM templates, customize widget configuration, and add any custom code, use the inner <script>
tag:
<dx-widget>
<script>
// Declare necessary functions here
// Use the `options` variable to extend the widget configuration
</script>
</dx-widget>
The content of this script is rendered into the jQuery Ready scope and doesn't pollute the global namespace.
Here are some examples:
<dx-data-grid on-cell-click="handleCellClick">
<script>
function handleCellClick(e) {
alert(e.displayValue);
}
</script>
</dx-data-grid>
Currently, DevExtreme ASP.NET Core Tag Helpers cannot be used to define nested widgets. To use templates, fallback to the JavaScript API:
<dx-data-grid>
<master-detail enabled="true" template="detailTemplate" />
<script>
function detailTemplate(container, options) {
$("<div>").dxDataGrid({ . . . }).appendTo(container);
}
</script>
</dx-data-grid>
The options
variable holding the widget configuration is available within each inner script block:
<dx-widget>
<script>
// Use a custom data source
options.dataSource = . . .
</script>
</dx-widget>