//Barcode entry, auto-complete functionfunctionAddautocomplete () {$ (' #txt_spuNo '). AutoComplete ({autoFocus:true, Source:function(Request, Response) {$.ajax ({URL:".. /handlerbase.ashx?action=tipbarcode ", data: {spu:request.term}, Success:function(data) {Response ($.parsejson (data)); } }); }, Minlength:3
});}
Custom Format:
<!DOCTYPE HTML><HTML><Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <title></title> <MetaCharSet= "Utf-8" /> <Linkhref=".. /content/themes/base/all.css "rel= "stylesheet" /> <Scriptsrc=".. /scripts/jquery-1.6.4.min.js "></Script> <Scriptsrc=".. /scripts/jquery-ui-1.11.4.min.js "></Script> <Scripttype= "Text/javascript"> $(function() {addautocomplete (); }); functionAddautocomplete () {$ ('#txt_Sku'). AutoComplete ({autoFocus:true, Source:function(Request, Response) {$.ajax ({URL:"http://localhost/jqueryuiapp.service/api/flowcard/getlist", data: {sku:request.term}, DataType:"JSON", Success:function(data) {response (data); } }); }, MinLength:3, select:function(event, UI) {if(Ui.item!= NULL) { $('#txt_Sku'). Val (Ui.item.SKU); $('#txt_BatchNo'). Val (Ui.item.BatchNo); $('#txt_GroupNo'). Val (Ui.item.GroupNo); } return false; }, Focus:function(event, UI) {$ ('#txt_Sku'). Val (Ui.item.SKU); return false; }}). AutoComplete ("instance"). _renderitem= function(UL, item) {return $('<table></table>'). Data ("Item.autocomplete", Item). Append ('<tr><td style= "width:140px;" >' +item. SKU+ '</td><td style= "width:50px;" >' +item. Batchno+ '</td><td style= "width:60px;" >' +item. Groupno+ "</td></tr>"). APPENDTO (UL); }; }; </Script></Head><Body>SKU:<inputID= "Txt_sku"width= "$" /><BR/>Batch:<inputID= "Txt_batchno"width= "$" /><BR/>Version number:<inputID= "Txt_groupno"width= "$" /></Body></HTML>
Background:
usingSystem.Runtime.Serialization;namespacejqueryuiapp.model{[DataContract] Public classFlowcardmodel {[DataMember] Public stringSKU {Get;Set; } [DataMember] Public stringBatchno {Get;Set; } [DataMember] Public stringGroupno {Get;Set; } }}
usingSystem.Collections.Generic;usingSystem.Web.Http;usingJqueryuiapp.model;namespacejqueryuiapp.service.controllers{ Public classFlowcardcontroller:apicontroller { PublicList<flowcardmodel>GetList () {varList =NewList<flowcardmodel>(); List. ADD (NewFlowcardmodel () {SKU ="12300000", Batchno ="P01", Groupno ="1" }); List. ADD (NewFlowcardmodel () {SKU ="12340000", Batchno ="P01", Groupno ="1" }); List. ADD (NewFlowcardmodel () {SKU ="12345000", Batchno ="P01", Groupno ="1" }); returnlist; } }}
jquery UI AutoComplete