O'Reilly logo

Moodle JavaScript Cookbook by Alastair Hole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Enabling editing

The DataTable control has an inline-editing feature, which allows the user to click on any cell that has editing enabled and modify its value. This updates the underlying DataSource which can then be retrieved and stored.

Getting ready

Open the datatable.js file for editing. We will add some extra properties to the column definition, and also subscribe to the DataTable's cellClickEvent.

How to do it...

Modify the columns definition by adding the new editor property:

var columns = [ { key: "chapter", label: "Chapter No.", formatter: "number", sortable: true, editor: new YAHOO.widget.TextboxCellEditor ({ validator: YAHOO.widget.DataTable.validateNumber } ), }, { key: "title", label: "Title", formatter: "string", sortable: true, editor: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required