Author Topic: autocomplete example when doing remote JSON  (Read 5444 times)

suvalkon

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
autocomplete example when doing remote JSON
« on: September 01, 2014, 08:54:52 am »
Hi

I am having a problem with autocomplete in a secondary (child) grid that comes from an external source and needs to be stored prior to usage in child grid.
How can I store it and use it later when the grid control is invoked.
The initial AJAX/JSON is done on entry into the page which gets data for multiple autoCompletes and selects (only once).

I have looked at your example with following code and am not sure how to get it to work for the situation I describe.
It is getting into this function but not setting up the source: attribute properly.

  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", "");
        });
    }

Also when you refresh the child grid ViewandData how can some of the same data also present in the primary grid (current row) be refreshed at the same time?

ie some data in child grid is editable and this needs to be immediately propagated to primary grid view on Update click.


Regards

Nick.


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6092
    • View Profile
Re: autocomplete example when doing remote JSON
« Reply #1 on: September 02, 2014, 04:41:17 pm »
1) If you store data for auto complete in a x variable, it could be assigned to autocomplete by source property.

Code: [Select]
var autoCompleteEditor = function (ui) {
        var $inp = ui.$cell.find("input");
        //initialize the editor
        $inp.autocomplete({
            source: x,
            selectItem: { on: true }, //custom option
            highlightText: { on: true }, //custom option
            minLength: 0
        }).focus(function () {
            //open the autocomplete upon focus               
            $(this).autocomplete("search", "");
        });
    }

2) Row can be refreshed / updated with the following methods:

http://paramquery.com/pro/api#method-refreshRow
http://paramquery.com/pro/api#method-updateRow

suvalkon

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: autocomplete example when doing remote JSON
« Reply #2 on: September 10, 2014, 01:47:17 pm »
Trying to save Json into array crashes at the source. Have you any example which stores json successfully for use later as a variable?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6092
    • View Profile
Re: autocomplete example when doing remote JSON
« Reply #3 on: September 10, 2014, 11:25:52 pm »
In this example array is stored in a variable books which is being used in autocomplete.

http://paramquery.com/pro/demos/editing_custom