jqgrid autocomplete with JSONArray in edit form
Hi, I'm new to jquery and am using the edit form from the jqgrid plugin.
I generate the autocomplete from an ajax function which returns a JSONArray but the autocomplete doesn't adjust to what i am typing, but it always shows all suggestions no matter what I type into the text field. Here is my code:
- colModel: [....
- {
- name: 'ScenarioName',
- index: 'ScenarioName',
- sortable: true,
- sorttype: 'text',
- editable: true,
- edittype: 'custom',
- editoptions: {
- custom_element : autocomplete_element,
- custom_value : autocomplete_value
- },
- hidelg: true
- }
- ....]
- function autocomplete_element(value, options) {
- // creating input element
- var $ac = $('<input type="text"/>');
- $ac.val(value);
- var $source = "ajax/listAutoComplete?fieldName="+options.id;
- $ac.autocomplete({
- source: $source,
- autosearch: true,
- minLength: 2,
- selectFirst: true
- });
- return $ac;
- }
- function autocomplete_value(elem, op, value) {
- if (op == "set") {
- $(elem).val(value);
- }
- return $(elem).val();
- }
If I change the source to a static array (e.g. ["1","11","111"]) then it works fine.
Any suggestions?