ParamQuery grid support forum

General Category => ParamQuery Pro Evaluation Support => Topic started by: engmag on November 09, 2016, 05:02:08 am

Title: Autocomplete for multiple columns
Post by: engmag on November 09, 2016, 05:02:08 am
Hi, I am using Autocomplete from the following example:  http://paramquery.com/pro/demos/editing_custom and wants to add support for many columns.

The code below supports column books and the countries. How can I add more local? Say that I have two columns (books, author) and I have one variable for each containing the values for Autocomplete.

It seems like the source can be defined in a dynamic way, but how does that syntax work?

Code: [Select]
source: (ui.dataIndx == "books" ? books : "/pro/demos/getCountries")
Can I add this to the same function below or is it recomended to add a separate function for each column?



 
Code: [Select]
       var autoCompleteEditor = function (ui) {
            var $inp = ui.$cell.find("input");

            //initialize the editor
            $inp.autocomplete({
                source: (ui.dataIndx == "books" ? books : "/pro/demos/getCountries"),
                selectItem: { on: true }, //custom option
                highlightText: { on: true }, //custom option
                minLength: 0
            }).focus(function () {
                //open the autocomplete upon focus               
                $(this).autocomplete("search", "");
            });
        }

BR
Title: Re: Autocomplete for multiple columns
Post by: paramvir on November 09, 2016, 09:50:00 am
Of course more than one column can use same autoComplete editor definition.

if( ui.dataIndx == di1 ){
  source = source1
}
else if( ui.dataIndx == di2 ){
  source = source2;
}
else if( condition.. ){
  so on...
}

$inp.autocomplete({
       source: source,
       ...
})
Title: Re: Autocomplete for multiple columns
Post by: engmag on November 10, 2016, 11:16:56 pm
Thanks!