Skip to content

Commit

Permalink
add doc about new isLocal property
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Apr 10, 2019
1 parent 78dad9d commit db4be0a
Show file tree
Hide file tree
Showing 10 changed files with 335 additions and 346 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This library is a Vue 2 wrapper for [jQuery DataTables](https://datatables.net/). It's a tiny wrapper that doesn't include anything, not even the datatables.net core library.

## Development
This library uses the NodeJS library `laravel-mix` to simplify build and packaging.
`laravel-mix` is use to simplify build and packaging.

Requirement: Install NodeJS, NPM

Expand Down Expand Up @@ -36,16 +36,16 @@ npm install vue-datatables-net
```

## Usage
This library default configuration and provide example for use with `bootstrap4` styling. Though, it allow for complete flexibility of customization with any other jQuery DataTables supported theme.
This library default configuration and provide example for `bootstrap4` styling. Though, it allow for complete flexibility of customization with any other jQuery DataTables supported theme.

> Example of imports for Bootstrap 4:
```html
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href='https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css'>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>

<script>
import VdtnetTable from 'vue-datatables-net'
Expand All @@ -64,7 +64,7 @@ import 'datatables.net-select-bs4/css/select.bootstrap4.min.css'

> See example [App](https://niiknow.github.io/vue-datatables-net/)
Example App demonstrate how to pass in overrides for our [jQuery DataTable](https://datatables.net/manual/options) default options - https://github.com/niiknow/vue-datatables-net/blob/master/example/app.vue
Example App demonstrate how to pass overrides for our [jQuery DataTable](https://datatables.net/manual/options) default options - https://github.com/niiknow/vue-datatables-net/blob/master/example/app.vue

**NOTE:**
Our example use a free API endpoint from [typicode](https://jsonplaceholder.typicode.com), which is simply a JSON endpoint. As a result, we needed to define a `dataSrc` wrapper like so:
Expand Down Expand Up @@ -188,14 +188,15 @@ fields: {
- `render` custom cell rendering function https://datatables.net/reference/option/columns.render
- `template` simple vue template for the field. See example App.
- `defaultOrder` null, asc/desc - the default/initial sort order
- `isLocal` same as setting both searchable and sortable to false

> It is important to understand why one should use `fields` and not `opts.columns`. Though, `fields` is optional, you can simply pass `opts.columns` definition if you do not wish to use `fields`.
> It is important to understand why it is better to use `fields` and not `opts.columns`. Though, `fields` is optional if one wish to use the raw `opts.columns` definition.
One `Purpose` of this component is to extend jQuery DataTables function and features, example:
* Simplification of features configuration, such as `select-checkbox` column, custom `action` buttons, and/or future Vue specific features.
* Allow for customizable table heading on a per-column basis; thereby, not having to define all html for each column header.
* Ability to have simple `template` field so you can pass schema JSON from static file or some API, instead of requiring to define a javascript `render` function. Though, the `render` function would provide best performance.
* Having schema also allow future features, such as: support of editable column/cell.
* Having schema also allow for future features, such as editable column/cell.

## Additional Headers
Many server-side usage require CSRF and/or API token headers. Since jQuery DataTables `options` are completely exposed as `opts`, simply use the native method per [jQuery DataTables example](https://editor.datatables.net/manual/security#Prevention)
Expand Down
6 changes: 3 additions & 3 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ __webpack_require__.r(__webpack_exports__);
},
doExport: function doExport(type) {
var parms = this.$refs.table.getServerParams();
parms.export = type;
parms["export"] = type;
window.alert('GET /api/v1/export?' + jQuery.param(parms));
}
}
Expand Down Expand Up @@ -442,7 +442,7 @@ __webpack_require__.r(__webpack_exports__);
*/
className: {
type: String,
default: 'table table-striped table-bordered nowrap w-100'
"default": 'table table-striped table-bordered nowrap w-100'
},

/**
Expand Down Expand Up @@ -566,7 +566,7 @@ __webpack_require__.r(__webpack_exports__);
var field = fields[k];
field.name = field.name || k; // disable search and sort for local field

if (field.utility) {
if (field.isLocal) {
field.searchable = false;
field.orderable = false;
} // generate
Expand Down
2 changes: 1 addition & 1 deletion example/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<head>
<meta charset="utf-8">
<title>vue-datatables-net demo</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href='https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css'>
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.8.94/css/materialdesignicons.min.css">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.5.95/css/materialdesignicons.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
</head>
<body>
<nav class="navbar navbar-light bg-light justify-content-between">
Expand Down
Loading

0 comments on commit db4be0a

Please sign in to comment.