Skip to content

Commit

Permalink
Merge pull request #7590 from olicooper/pr/datatable-createajax
Browse files Browse the repository at this point in the history
Improve DataTable.Net AJAX Adapter
  • Loading branch information
hikalkan committed Feb 9, 2021
2 parents 9ecf099 + 9217fcf commit eb29c8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion docs/en/UI/AspNetCore/Data-Tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The `createAjax` also supports you to customize request parameters and handle th
**Example:**

````csharp
var inputAction = function () {
var inputAction = function (requestData, dataTableSettings) {
return {
id: $('#Id').val(),
name: $('#Name').val(),
Expand All @@ -131,6 +131,14 @@ var responseCallback = function(result) {
ajax: abp.libs.datatables.createAjax(acme.bookStore.books.book.getList, inputAction, responseCallback)
````

If you don't need access or modify the `requestData` or the `dataTableSettings`, you can specify a **simple object** as the second parameter.

**Note:** This option should not be used if you need to customise any of the following options: `maxResultCount`, `skipCount`, `sorting`, `filter` - these options will be overwritten by the `createAjax` function so you should specify an `inputAction` **function** instead.

````javascript
ajax: abp.libs.datatables.createAjax(acme.bookStore.books.book.getList, { id: $('#Id').val(), name: $('#Name').val() })
````

### Row Actions

`rowAction` is an option defined by the ABP Framework to the column definitions to show a drop down button to take actions for a row in the table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@
};
}
return function (requestData, callback, settings) {
var input = inputAction ? inputAction(requestData, settings) : {};
var input = typeof inputAction === 'function'
? inputAction(requestData, settings)
: typeof inputAction === 'object'
? inputAction : {};

//Paging
if (settings.oInit.paging) {
Expand Down

0 comments on commit eb29c8b

Please sign in to comment.