Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 17af831

Browse files
committed
docs: improve autocompleter docs
1 parent 2cd23d5 commit 17af831

File tree

2 files changed

+30
-47
lines changed

2 files changed

+30
-47
lines changed

docs/column-functionalities/editors/Autocomplete-Editor-(Kraaden-lib).md

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ You could also define certain options as a global level (for the entire grid or
109109

110110
```ts
111111
this.gridOptions = {
112-
defaultEditorOptions: {
112+
defaultEditorOptions: {
113113
autocompleter: { debounceWaitMs: 150 }, // typed as AutocompleterOption
114114
}
115115
}
@@ -144,9 +144,10 @@ export class GridBasicComponent {
144144
fetch: (searchText, updateCallback) => {
145145
// assuming your API call returns a label/value pair
146146
yourAsyncApiCall(searchText) // typically you'll want to return no more than 10 results
147-
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]); })
148-
.catch(error => console.log('Error:', error);
149-
},
147+
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]))
148+
.catch(error => console.log('Error:', error));
149+
},
150+
}
150151
} as AutocompleterOption,
151152
},
152153
];
@@ -177,8 +178,9 @@ this.columnDefinitions = [
177178
fetch: (searchText, updateCallback) => {
178179
// assuming your API call returns a label/value pair
179180
yourAsyncApiCall(searchText) // typically you'll want to return no more than 10 results
180-
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]); })
181-
.catch(error => console.log('Error:', error);
181+
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]))
182+
.catch(error => console.log('Error:', error));
183+
}
182184
},
183185
} as AutocompleterOption,
184186
}
@@ -215,8 +217,9 @@ export class GridBasicComponent {
215217
minLength: 1,
216218
fetch: (searchText, updateCallback) => {
217219
yourAsyncApiCall(searchText) // typically you'll want to return no more than 10 results
218-
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]); })
219-
.catch(error => console.log('Error:', error);
220+
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]))
221+
.catch(error => console.log('Error:', error));
222+
}
220223
},
221224
renderItem: {
222225
layout: 'twoRows',
@@ -281,7 +284,7 @@ export class GridBasicComponent {
281284
},
282285
fetch: (searchText, updateCallback) => {
283286
yourAsyncApiCall(searchText) // typically you'll want to return no more than 10 results
284-
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]); })
287+
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]))
285288
.catch(error => console.log('Error:', error);
286289
},
287290
renderItem: {
@@ -362,14 +365,10 @@ export class GridBasicComponent {
362365
editorOptions: {
363366
minLength: 3, // minimum count of character that the user needs to type before it queries to the remote
364367
fetch: (searchText, updateCallback) => {
365-
$.ajax({
366-
url: 'http://gd.geobytes.com/AutoCompleteCity',
367-
dataType: 'jsonp',
368-
data: {
369-
q: searchText // geobytes requires a query with "q" queryParam representing the chars typed (e.g.: gd.geobytes.com/AutoCompleteCity?q=van
370-
},
371-
success: (data) => updateCallback(data)
372-
});
368+
// assuming your API call returns a label/value pair
369+
yourAsyncApiCall(searchText) // typically you'll want to return no more than 10 results
370+
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]))
371+
.catch(error => console.log('Error:', error));
373372
}
374373
},
375374
},
@@ -382,16 +381,10 @@ export class GridBasicComponent {
382381
editorOptions: {
383382
minLength: 3, // minimum count of character that the user needs to type before it queries to the remote
384383
fetch: (searchText, updateCallback) => {
385-
$.ajax({
386-
url: 'http://gd.geobytes.com/AutoCompleteCity',
387-
dataType: 'jsonp',
388-
data: {
389-
q: searchText
390-
},
391-
success: (data) => {
392-
updateCallback(data);
393-
}
394-
});
384+
// assuming your API call returns a label/value pair
385+
yourAsyncApiCall(searchText) // typically you'll want to return no more than 10 results
386+
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]))
387+
.catch(error => console.log('Error:', error));
395388
}
396389
},
397390
}

docs/column-functionalities/filters/Autocomplete-Filter-(Kraaden-lib).md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,10 @@ export class GridBasicComponent implements OnInit {
118118
editorOptions: {
119119
minLength: 3, // minimum count of character that the user needs to type before it queries to the remote
120120
fetch: (searchText, updateCallback) => {
121-
$.ajax({
122-
url: 'http://gd.geobytes.com/AutoCompleteCity',
123-
dataType: 'jsonp',
124-
data: {
125-
q: searchText // geobytes requires a query with "q" queryParam representing the chars typed (e.g.: gd.geobytes.com/AutoCompleteCity?q=van
126-
},
127-
success: (data) => updateCallback(data)
128-
});
121+
// assuming your API call returns a label/value pair
122+
yourAsyncApiCall(searchText) // typically you'll want to return no more than 10 results
123+
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]))
124+
.catch(error => console.log('Error:', error));
129125
}
130126
},
131127
},
@@ -138,18 +134,12 @@ export class GridBasicComponent implements OnInit {
138134
filterOptions: {
139135
minLength: 3, // minimum count of character that the user needs to type before it queries to the remote
140136
fetch: (searchText, updateCallback) => {
141-
$.ajax({
142-
url: 'http://gd.geobytes.com/AutoCompleteCity',
143-
dataType: 'jsonp',
144-
data: {
145-
q: searchText
146-
},
147-
success: (data) => {
148-
updateCallback(data);
149-
}
150-
});
151-
}
152-
},
137+
// assuming your API call returns a label/value pair
138+
yourAsyncApiCall(searchText) // typically you'll want to return no more than 10 results
139+
.then(result => updateCallback((results.length > 0) ? results : [{ label: 'No match found.', value: '' }]))
140+
.catch(error => console.log('Error:', error));
141+
},
142+
}
153143
}
154144
}
155145
];

0 commit comments

Comments
 (0)