Skip to content

Commit 0c693ea

Browse files
author
syshex
committed
documentation
1 parent fc22f36 commit 0c693ea

File tree

1 file changed

+110
-1
lines changed

1 file changed

+110
-1
lines changed

README.md

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ TODO UPDATE CHANGELOG
3535
* Select display columns
3636
* Pagination
3737
* On Table Editing
38+
* Remote data loading
39+
* Remote data processing
3840

3941

4042
## Requirements
@@ -182,6 +184,21 @@ Or add the js script to your html (download from [releases](https://github.com/j
182184
required: false,
183185
default: 10,
184186
},
187+
/**
188+
* If loading of table is to be done through ajax, then this object must be set
189+
*/
190+
ajax: {
191+
type: Object,
192+
required: false,
193+
default: function () {
194+
return {
195+
enabled: false,
196+
url: "",
197+
method: "GET",
198+
delegate: false,
199+
}
200+
}
201+
},
185202
},
186203
187204
```
@@ -217,6 +234,92 @@ Column with Title "Name" , which is visible and editable:
217234
}
218235
```
219236

237+
### AJAX Configuration
238+
239+
Ajax Object properties:
240+
241+
* enabled : to enable loading through ajax call, enable this
242+
* url: the URL where to request the data
243+
* methods: GET and POST are the valid methods allowed
244+
* delegate: False = just get all the data and do processing on browser; True = Ask for data as needed, and all processing is done on the server side.
245+
246+
247+
#### Example AJAX config for Remote Loading
248+
249+
This configuration will only make one request to the server, to get all the data and load it straight into the browser.
250+
251+
```javascript
252+
ajax: {
253+
enabled: true,
254+
url: "http://localhost:9430/data/test",
255+
method: "GET",
256+
delegate: false,
257+
},
258+
```
259+
260+
#### Example AJAX config for Remote Processing
261+
262+
This configuration will only make many requests to the server, each time data ir needed, or any processing is required: for filtering, ordering, pagniation, changes of page size, etc.
263+
264+
```javascript
265+
ajax: {
266+
enabled: true,
267+
url: "http://localhost:9430/data/test",
268+
method: "GET",
269+
delegate: true,
270+
},
271+
```
272+
273+
### Ajax Request and Expected Response
274+
275+
#### Ajax Request Parameters Sent
276+
277+
When Ajax is enabled, the following parameters are sent with each request for the URL specified:
278+
279+
- `sortcol` : The name of the column to sort by (only sent when `delegate` is true, otherwise will be null)
280+
- `sortdir` : The sorting direction "ASC" or "DESC" (only sent when `delegate` is true, otherwise will be null)
281+
- `filter` : The filter to be used (only sent when `delegate` is true, otherwise will be null)
282+
- `page` : The number of the page being requested ( when delegate is false, it will always be 1 )
283+
- `pagesize` : The number of records being requested.
284+
- `echo` : A unique number for the request.
285+
286+
#### Ajax Expected Response
287+
288+
For all requests, vue-bootstrap-table expects an object of the following type:
289+
290+
```javascript
291+
{
292+
echo: INTEGER,
293+
filtered: INTEGER,
294+
data: [OBJECT],
295+
},
296+
```
297+
298+
Where:
299+
300+
- `echo` : is the same integer the request provided.
301+
- `filtered` : is the total amount of entries for the request, and is used for pagination
302+
- `data` : is an Array of Object with the entries.
303+
304+
Example:
305+
306+
```javascript
307+
{
308+
echo: 1,
309+
filtered: 2000,
310+
data: [
311+
{
312+
id: 1,
313+
name: "Rui"
314+
},
315+
{
316+
id: 2,
317+
name: "Gustavo"
318+
},
319+
],
320+
},
321+
```
322+
220323
## Events
221324

222325
* `cellDataModifiedEvent` - When a cell is edited, an `cellDataModifiedEvent` event is dispatched.
@@ -250,14 +353,20 @@ If you have a feature request, please add it as an issue or make a pull request.
250353
- [x] Column picker
251354
- [x] Pagination
252355
- [x] Editing
253-
- [ ] Ajax
356+
- [x] Ajax
254357
- [ ] Responsive
255358
- [ ] Dates sorting
256359
- [ ] Keyboard navigation
257360

258361

259362
## Changelog
260363

364+
### 1.1.0
365+
366+
* Remote data loading (through ajax call)
367+
* Remote data processing (through ajax calls)
368+
* Loading overlay
369+
261370
### 1.0.2
262371

263372
* Pagination working

0 commit comments

Comments
 (0)