From a2dec246e56b68b48938da7b6649998cb3d5ca6e Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 3 Jan 2015 11:30:02 +1100 Subject: [PATCH] handler -> postbackHandlerName (doesn't do the same thing as traditional 'handler') --- modules/backend/widgets/Table.php | 4 ++-- modules/backend/widgets/table/README.md | 10 +++++----- modules/backend/widgets/table/assets/js/table.js | 4 ++-- modules/backend/widgets/table/partials/_table.htm | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/backend/widgets/Table.php b/modules/backend/widgets/Table.php index c7450b6ca..3a3fe8191 100644 --- a/modules/backend/widgets/Table.php +++ b/modules/backend/widgets/Table.php @@ -100,7 +100,7 @@ class Table extends WidgetBase $this->vars['recordsKeyFrom'] = $this->recordsKeyFrom; $this->vars['recordsPerPage'] = $this->getConfig('recordsPerPage', false) ?: 'false'; - $this->vars['handler'] = $this->getConfig('handler', 'onSave'); + $this->vars['postbackHandlerName'] = $this->getConfig('postbackHandlerName', 'onSave'); $this->vars['adding'] = $this->getConfig('adding', true); $this->vars['deleting'] = $this->getConfig('deleting', true); $this->vars['toolbar'] = $this->getConfig('toolbar', true); @@ -153,7 +153,7 @@ class Table extends WidgetBase return $result; } - protected function isClientDataSource() + protected function isClientDataSource() { return $this->dataSource instanceof \Backend\Classes\TableClientMemoryDataSource; } diff --git a/modules/backend/widgets/table/README.md b/modules/backend/widgets/table/README.md index 2a5b808d9..bcfe4076d 100644 --- a/modules/backend/widgets/table/README.md +++ b/modules/backend/widgets/table/README.md @@ -78,8 +78,8 @@ The options below are listed in the JavaScript notation. Corresponding data attr - `columns` - column definitions in JSON format, see the server-side column definition format below. - `rowSorting` - enables the drag & drop row sorting. The sorting cannot be used with the pagination (`recordsPerPage` is not `null` or `false`). - `keyColumn` - specifies the name of the key column. The default value is **id**. -- `postback` - post the client-memory data source data to the server automatically when the parent form gets submitted. The default value is `true`. The option is used only with client-memory data sources. When enabled, the data source data is available in the widget's server-side data source: `$table->getDataSource()->getRecords();` The data postback occurs only of the request handler name matches the `handler` option value. -- `handler` - AJAX data handler name for the automatic data postback. The data will be posted only when the AJAX request posts data matching this handler name. The default value is **onSave**. +- `postback` - post the client-memory data source data to the server automatically when the parent form gets submitted. The default value is `true`. The option is used only with client-memory data sources. When enabled, the data source data is available in the widget's server-side data source: `$table->getDataSource()->getRecords();` The data postback occurs only of the request handler name matches the `postbackHandlerName` option value. +- `postbackHandlerName` - AJAX data handler name for the automatic data postback. The data will be posted only when the AJAX request posts data matching this handler name. The default value is **onSave**. - `adding` - determines whether users can add new records. Default value is **true**. - `deleting` - determines whether users can delete records. Default value is **true**. - `toolbar` - determines whether the toolbar is visible. The default value is **true**. @@ -170,7 +170,7 @@ The widget is configured with YAML file. Required parameters: * `dataSource` - The data source class. Should specify the full qualified data source class name or alias. See the data source aliases below. * `keyFrom` - name of the key column. The default value is **id**. * `recordsPerPage` - number of records per page. If not specified, the pagination will be disabled. -* `handler` - AJAX data handler name for the automatic data postback. The data will be posted only when the AJAX requests posts data to this handler. The default value is **onSave**. This parameter is applicable only with client-memory data sources. +* `postbackHandlerName` - AJAX data handler name for the automatic data postback. The data will be posted only when the AJAX requests posts data to this handler. The default value is **onSave**. This parameter is applicable only with client-memory data sources. * `adding` - indicates if record deleting is allowed, default is **true**. * `deleting` - indicates if record deleting is allowed, default is **true**. * `toolbar` - specifies if the toolbar should be visible, default is **true**. @@ -247,11 +247,11 @@ $dataSource->purge(); The server-side data sources (PHP) automatically maintain the actual data, but that mechanism for the client-memory and server-memory data sources is different. -In case of the client-memory data source, the table widget adds the data records to the POST, when the form is saved (see `postback` and `handler` options). On the server side the data is inserted to the data source by the table widget. +In case of the client-memory data source, the table widget adds the data records to the POST, when the form is saved (see `postback` and `postbackHandlerName` options). On the server side the data is inserted to the data source by the table widget. The server-memory data source always automatically maintain its contents in synch with the client using AJAX, and POSTing data is not required. -In PHP reading data from a data source of any type looks like this (it should be in the AJAX handler that saves the data, for the client-memory data source the handler name should match the `handler` option value): +In PHP reading data from a data source of any type looks like this (it should be in the AJAX handler that saves the data, for the client-memory data source the handler name should match the `postbackHandlerName` option value): ``` public function onSave() diff --git a/modules/backend/widgets/table/assets/js/table.js b/modules/backend/widgets/table/assets/js/table.js index f835a2d79..1fe291089 100644 --- a/modules/backend/widgets/table/assets/js/table.js +++ b/modules/backend/widgets/table/assets/js/table.js @@ -664,7 +664,7 @@ } Table.prototype.onFormSubmit = function(ev, data) { - if (data.handler == this.options.handler) { + if (data.handler == this.options.postbackHandlerName) { this.unfocusTable() data.options.data[this.options.alias + 'TableData'] = this.dataSource.getAllData() } @@ -844,7 +844,7 @@ recordsPerPage: false, data: null, postback: true, - handler: 'onSave', + postbackHandlerName: 'onSave', adding: true, deleting: true, toolbar: true, diff --git a/modules/backend/widgets/table/partials/_table.htm b/modules/backend/widgets/table/partials/_table.htm index 352b18a73..06f50d0f8 100644 --- a/modules/backend/widgets/table/partials/_table.htm +++ b/modules/backend/widgets/table/partials/_table.htm @@ -4,7 +4,7 @@ class="control-table" data-columns="" data-data="" - data-handler="" + data-postback-handler-name="" data-adding="" data-deleting="" data-toolbar=""