Forum


21:48

20/08/2011

After many days of frustration and research, i have come up with helpful info on using jquery UI autocomplete with jqgrid.
Please read the last post in this thread: http://www.trirand.com/blog/?p.....id-posted/
03:18

27/09/2012

Hi,
I am unable to find your post..
I am using the latest version of jqGrid, and trying to attach the autoComplete event to 2 fields in the edit Form. The callbacks are called fine, the only problem is the drop down list does not show and is not displayed. Appreciate beyond words can express for your help and any info you can provide. Here is my code:
I have the autoComplete function attached to the field in the onInitializeForm method (the field whch is defined in my ColModel as PlatformCode_ItemMajor_Code is the one I want it to have autoComplete (I am using ASP.NET MVC 3 using the free version of jqGrid)
onInitializeForm: function (formId) {
$("#PlatformCode_ItemMajor_Code").autocomplete({
source: function (request, response) {
$.ajax({
url: "/DataManagement/findItemMajors", type: "POST", dataType: "json",
data: { searchText: request.term, maxResults: 10 },
success: function (data) {
response($.map(data, function (item) {
return { label: item.Code + ":" + item.Name, value: item.Code, id: item.Id }
}))
}
})
},
select: function (event, ui) {
// alert("ui.item.Id="+ui.item.id);
$("#PlatformCode_ItemMajorId").val(ui.item.id);
var str = $("#PlatformDescription").val();
// alert("str="+str);
var substr = str.split("-");
if (substr[1] != null)
str = ui.item.label.split(':')[1] + "-" + substr[1];
else
str = ui.item.label.split(':')[1] + "-";
//alert("str="+str+",substr[0]="+substr[0]+",str[1]="+substr[1]+",ui.item.label.split(':')[1]="+ui.item.label.split(':')[1]);
if (substr != null && substr != "" && substr[1] != null && substr[0] != null)
str = ui.item.label.split(':')[1] + "-" + substr[1];
$("#PlatformDescription").val(str);
alert("$(#PlatformDescription)=" + $("#PlatformDescription").val());
}
});
00:07

20/08/2011

All i know is that you need to attach the jquery autocomplete widget to the datainit object of the editoptions method in jqgrid as follows…
{name:'cu.LastName', index:'cu.LastName', width:150, fixed: true, align:'center', hidden:false, sortable: true, editable: true, edittype: 'text',
editoptions:{size:25, dataInit:function(e){$(e).autocomplete({ source: 'php/cu-autocomplete-script.php',minLength: 1,
select: function(event, ui){event.preventDefault();
var name = ui.item.label.split('. ', 2);
// update editform workorder, customer and billing address fields with server side table data.
$('input#id' ).val(ui.item.value);
$('input#cu.FRID' ).val(ui.item.FRID);
$('input#cu.BusinessName' ).val(ui.item.BusinessName);
$('input#cu.LastName' ).val(name[0]);
$('input#cu.FirstName' ).val(name[1]);
$('input#cu.Street' ).val(ui.item.Street);
$('input#cu.City' ).val(ui.item.City);
$('select#cu.STID' ).val(ui.item.STID); // must use id for select box to update after autocomplete.
},
focus: function(event, ui) {event.preventDefault();}})}},
formoptions:{rowpos: 3, label:'Customer Last Name', elmprefix:'* ', elmsuffix:' (Min. 2 characters required for search)'}, editrules:{required:true}},
It really that simple.
Most Users Ever Online: 715
Currently Online:
38 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66