November 2nd, 2014

Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Autocomplete in jQgrid with JSON data returned by a Php page
New Member
Forum Posts: 1
Member Since:
sp_UserOfflineSmall Offline

I was trying to implement autocomplete for a textbox which is generated by jQgrid.

When I use data such as ["blah","hello","howdy"] in source of $ac.autocomplete,

the thing seems to work nicely. But I have around 2000 rows of data to search

from. The jQgrid form is working correctly and I am being able to add & edit data.

Also, I have tested the php page which displays proper JSON data when I point a

browser at it. I am only struck with autocomplete with data returned from the php

page since I am not much comfortable with jQuery. Please help.

A Php page would return JSON data. Here's what I was able to do so far: (Please help)

function autocomplete_element(value, options) {

  var $ac = $('<input type="text"/>');



    source: function(request, response) {

        $.getJSON("autocomplete.php", { q: request.term }, response);



  return $ac;


function autocomplete_value(elem, op, value) {

  if (op == "set") {



  return $(elem).val();





    datatype: 'xml',

    mtype: 'GET',

    colNames:['Column Name'],

    colModel :[

        {name:'columnid', index:'columnid', width:50, edittype:'custom',

            editoptions: {

                custom_element : autocomplete_element,

                custom_value   : autocomplete_value







///         THE PHP PAGE                    ////







    $term = trim(strip_tags($_REQUEST['q']));//retrieve the search term that autocomplete sends

    $qstring = "SELECT description as value, id FROM test WHERE name LIKE '%".$term."%'";

    $result = mysql_query($qstring);//query the database for entries containing the term

    while ($row = mysql_fetch_array($result,MYSQL_ASSOC))//loop through the retrieved values




        $row_set[] = $row;//build an array


    echo json_encode($row_set);//format the array into json data


Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam,

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information