Thursday 21st January, 2016

Generator update

Editor is all about saving time for developers creating CRUD systems - who wants to write yet more upload logic!? While Editor can reduce an editable table to just a handful of lines on the client and server, it can still be a little daunting to get started with a new API, particularly if you are relatively new to the web-programming world. So to get up an running with Editor as quickly as possible, Generator for Editor exists.

With Generator all you need to do is fill in a few details about the table that you want to create and it will produce the code for you. Multiple field types, validation and form or table only data can easily be configured with Generator.

While Generator has been available since the initial release of Editor it hasn't seen any updates, until now. In this post I'll run through some of the new features of Generator, and encourage you to try it out as a great way to start working with Editor.

Easier form input

The basic functionality and features offered by Generator haven't really changed - it will still let you pick the server platform, database type and what fields you want to display, but the form has been redesigned to be much more approachable. Rather than showing all of the options available, all at the same time, now only the field name and type are shown (optionally with a values input for some field types), with a link that will activate an Editor window that can be used to customise the field further (this uses Editor in standalone mode - its important to eat your own dogfood after all!).

Generator fields display

Run immediately

Previously when using Generator, the only way to see the results of your configuration were to download the package, setup the database connection, create the SQL table and finally load the page in your browser. While not arduous, if you just want to quickly try a configuration out it can be a little fiddly. To help resolve this and show a customised Editor in just a few seconds a "Run now" button has been added.

"Run now" will build the configured package and execute it live on the server so you can see the results immediately. It is only designed to be used as a test page for the input configuration (you would down the package if you wanted to retain the table), so built tables will be deleted one hour after they are constructed, but otherwise they are fully functional editable tables.

Create tables

In order to keep the number of steps from starting a Generator download to actually using the table to a minimum, Generator's server-side code will now execute a CREATE TABLE IF NOT EXISTS statement when loaded, building the SQL table if needed, so you don't need to load up phpMyAdmin, pgAdmin, SQL Server or any other database program to create the table. Of course if you have an existing table by the given table name, then no action will be taken.

The CREATE TABLE statement can then be removed from the server-side code once the table exists in order to reduce the number of queries made on each data request. Both the PHP and C# code generated have comments noting this.

Give it a go!

While this isn't a complete reimplementation of Generator, it is a good evolution of what has come before and I'm quite excited about it as it makes Editor even more approachable. Like all aspects of DataTables, feedback is always welcome - let me know how you get on with the updated Generator by posting in the forum.