ODataDB Sample 04 - Order Form

This example highlights the following ODataDB features:

Here is an embedded form.

Embedding Forms

To embed the form, add odatadb.css to the head, odatadb.js at the bottom, and place the control like this:

<div class="odatadb-control" data-url="v4/mssql-041/default/en-us/s04_usp_basket()"></div>

Dynamic Parameter Values

To try dynamic parameter values, change the category in the first parameter.
You will see the updated value lists in other parameters.

The idea is simple. Just add a parameter to a stored procedure that selects values.
You can find the source codes of the procedures in the code browser below.

Here is the configuration of parameter values.

Calculated columns

To test calculated columns, change the amount in any cell.

The trick is in the use of formula =[@amount]*[@price] in the Total column, defined in the view_items.

ODataDB supports Excel formulas that use column names and JavaScript-supported operators.

Conditional Formatting

This sample loads formatting rules from the xls.handlers table.

You can use a free version of the SaveToDB add-in to convert Excel conditional formatting to such formats.
Use Wizards, Developer Tools, Show Table Format.

Protecting Cells

And the last exciting thing is protecting cells by the cell change handlers.

Try to delete any name or set the amount in the category line.

The server returns error 500, and ODataDB rollbacks the change.

To prevent cell changes, raise an exception. For example, in SQL Server, use RAISERROR (@message, 11, 0).

Here is an SQL definition of the s04.usp_basket_change procedure used as a handler.

Conclusion

This sample shows how database developers can create interactive web forms.

Just create a cell change handler, procedures to select parameter values, and add the conditional formatting.

Select Excel formulas to have calculated columns and embed the form into any corporate web page.

Code Browser



You can download samples for any supported database platform with the SaveToDB SDK.