我正在尝试以表格格式显示自动填充中的数据。我只剩下显示用户无法选择的标题。
到目前为止我的代码:
<script type="text/javascript">
function pageLoad(sender, args) {
$(function () {
$("#<%=txt.ClientID %>").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/Webservice.asmx/GetDetails") %>',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
async: false,
mustMatch: true,
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('^')[0],
val: item.split('^')[1]
}
}))
},
error: function (response) {
},
failure: function (response) {
}
});
},
select: function (e, i) {
$("#<%=hdnC.ClientID %>").val(i.item.val);
if (i.item.val == "No Records Found") {
$("#<%=hdnC.ClientID %>").val(-1);
document.getElementById('<%=txt.ClientID%>').value = "";
return false;
}
},
minLength: 0
}).bind('focus', function () { $(this).autocomplete("search"); })
.data("autocomplete")._renderItem = function(ul, item) {
return $("<li></li>").data("item.autocomplete", item).append("<a><table><tr><td width='200px'>" + item.label + "</td>" + "<td>" + item.val.split('~')[6] + "</td></tr></table></a>").appendTo(ul);
};
});
}
</script>