Forum

November 2nd, 2014
A A A
Avatar

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_TopicIcon
Integrate jqGrid with Autocomplete
19/11/2009
13:08
Avatar
davidbemenderfer
Member
Members
Forum Posts: 17
Member Since:
10/11/2009
sp_UserOfflineSmall Offline

Per Tony's advice, I'm trying to implement autocomplete into my project.  I'm using the jquery.ui.autocomplete.js file version 1.1 (the latest).  This version is supposed to be included in an upcoming version of the jQuery UI package 1.8.  I'm trying to implement using JSON but my php is not very good.  If my below code is close, maybe someone can tell me what I'm doing wrong.  If I'm off base, maybe someone can verify or provide a sample of the server side JSON results and a client side example.  When complete, I will post my working example.  The jqGrid documentation says this can be done but does not provide an example.

Thanks in advance,

-David

My colModel code

{name:'TimeCode_ID',   index:'TimeCode_ID',   width:100,  editable:true,  editoptions:{ dataInit : function (elem) {$(elem).autocomplete();}}},

My autocomplete function

function auto_complete(id){
     jQuery(”#”+id+”TimeCode_ID”,”#list”).autocomplete({
      //$(”#TimeCode_ID”).autocomplete({
      cache: {limit: 15},
      source: function(request, response) {
       $.ajax({
        dataType: “JSON”,
        data: {
         style: “full”,
         maxRows: 15,
         name_startsWith: request.term
        },
        success: function(data) {
         response($.map(data.geonames, function(item) {
          return {
           label: item.name + (item.adminName1 ? “, ” + item.adminName1 : “”) + “, ” + item.countryName,
           result: item.name
          }
         }))

        }
       })
      },
      minLength: 1,
      change: function(event, ui) {
       log(ui.item ? (”Selected: ” + ui.item.label) : “Nothing selected, input was ” + this.value);
      },
      open: function() {
       $(this).removeClass(”ui-corner-all”).addClass(”ui-corner-top”);
      },
      close: function() {
       $(this).removeClass(”ui-corner-top”).addClass(”ui-corner-all”);
      }
     });
    };

My JSON file results

[{labortype_id: "1",LaborType: "Paralegal Time"}, {labortype_id: "2",LaborType: "Mediator Setup Time"}, {labortype_id: "3",LaborType: "Reschedule(s)"}, {labortype_id: "4",LaborType: "Mediator Preparation Time"}, {labortype_id: "5",LaborType: "Mediate Case"}, {labortype_id: "6",LaborType: "Post Mediation Time"}, {labortype_id: "7",LaborType: "Cancellation"}];

Code that generates the JSON file

 dblCounter = 1
 response.write “["
 While Not (rs.EOF Or rs.BOF)
  if dblCounter > 1 then response.write ", "
  response.write "{"
  response.write "labortype_id: """ & trim(rs("labortype_id")) & ""","
  response.write "LaborType: """ & trim(rs("LaborType"))& """"
  response.write "}"
  dblCounter = dblCounter + 1
  response.flush
  rs.MoveNext
 Wend
 response.write "];”
Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
55 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, greg.valainis@pa-tech.com

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information