jquery自动完成不显示浮点数据类型值

jquery自动完成不显示浮点数据类型值,jquery,asp.net,ajax,jquery-ui-autocomplete,Jquery,Asp.net,Ajax,Jquery Ui Autocomplete,我正在jquery自动完成中检索一些多列数据。一切正常,但问题是自动完成只显示那些不包含浮点或双精度值的值。对于ex-如果产品名是jQuery2.0,那么它只检索(或显示)jQuery2 我尝试像这样格式化我的web服务的查询 select format(ProductName , '0.00') as ProductName, ProductCode, format(Mrp,'0.00') as Mrp,PackingName,format(SaleRate,'0.00') as SalesR

我正在jquery自动完成中检索一些多列数据。一切正常,但问题是自动完成只显示那些不包含浮点或双精度值的值。对于ex-如果产品名是jQuery2.0,那么它只检索(或显示)jQuery2 我尝试像这样格式化我的web服务的查询

select format(ProductName , '0.00') as ProductName, ProductCode, format(Mrp,'0.00') as Mrp,PackingName,format(SaleRate,'0.00') as SalesRate ,SchemeRatio  from ProductMaster where " & "ProductName like @SearchText + '%'
但这并没有改变任何事情。 我需要做什么改变,请帮忙,提前谢谢

这是我的jquery代码

<script type ="text/javascript">

   $(document).ready(function () {

       $("#<%#txtSearch.ClientID %>").autocomplete({
           source: function (request, response) {
               $.ajax({
                   url: '<%#ResolveUrl("~/Service.asmx/GetCustomers") %>',
                   data: "{ 'prefix': '" + request.term + "'}",
                   dataType: "json",
                   type: "POST",
                   contentType: "application/json; charset=utf-8",
                   success: function (data) {
                       var safe = data
                       response($.map(safe.d, function (item) {

                           return {
                               label: item.split('.')[0],
                               value: item.split('-')[0]

                           }

                       }))


                   },
                   error: function (response) {
                       alert(response.responseText);
                   },
                   failure: function (response) {
                       alert(response.responseText);
                   }
               });
           },
           select: function (e, i) {

               $("#<%#hfProductId.ClientID %>").val(i.item.value);
           },
           minLength: 1,

       });

       $("#<%#txtSearch.ClientID %>").autocomplete().data("ui-autocomplete")._renderItem = function (ul, item) {
           var line_item = '';
           line_item += "<a><div class='search_row'>";
           line_item += "<div class='sku'>Product Name-&nbsp;&nbsp;&nbsp;&nbsp;" + item.label.split('-')[0] + "</div>" + "<div class='productcode'>Product Code-&nbsp;&nbsp;&nbsp;&nbsp;" + item.label.split('-')[1] + "</div>" + "<div class='sku'>Product Mrp-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + item.label.split('-')[2] + "</div>" + "<div class='sku'>Packing Name-&nbsp;&nbsp;&nbsp;" + item.label.split('-')[3] + "</div>" + "<div class='sku'>Scheme Ratio-&nbsp;&nbsp;&nbsp;" + item.label.split('-')[4] + "</div>";
           line_item += "<hr>";

           line_item += "</div></a>";

           return $("<li>")
           .append(line_item)
           .appendTo(ul);
       };

 });


</script>

$(文档).ready(函数(){
$(“#”)自动完成({
来源:功能(请求、响应){
$.ajax({
url:“”,
数据:“{'前缀':'”+request.term+“}”,
数据类型:“json”,
类型:“POST”,
contentType:“应用程序/json;字符集=utf-8”,
成功:功能(数据){
var安全=数据
响应($.map(safe.d,函数(项)){
返回{
标签:item.split('.')[0],
值:item.split('-')[0]
}
}))
},
错误:函数(响应){
警报(response.responseText);
},
故障:功能(响应){
警报(response.responseText);
}
});
},
选择:功能(e,i){
$(“#”)val(i.item.value);
},
最小长度:1,
});
$(“#”).autocomplete().data(“ui自动完成”)。\u renderItem=函数(ul,项){
变量行_项=“”;
行_项+=“”;
行项目+=“产品名称-”+项目.标签.拆分(“-”)[0]+“+”产品代码-“+项目.标签.拆分(“-”)[1]+“+”产品Mrp-“+项目.标签.拆分(“-”)[2]+“+”包装名称-“+项目.标签.拆分(“-”)[3]+“+”方案比率-“+项目.标签.拆分(“-”)[4]+”;
行项目+=“
”; 行_项+=“”; 返回$(“
  • ”) .append(第_行项目) .附录(ul); }; });
  • 我认为您需要在jquery端应用该函数

    比如说

    parseFloat(yourValue).toFixed(2)
    

    @Nyoman-我犯了一个非常愚蠢的错误,我用split('.')拆分了所有记录,这就是为什么我没有得到下一个数字,我只是更改了代码

     response($.map(safe.d, function (item) {
    
                           return {
                               label: item.split('.')[0],
                               value: item.split('-')[0]
    
                           }
    


    它成功了

    我试过了,但现在显示的是NaN,尽管所有的值都是数字。这是我的jquery代码'line_item+=“”+item.label.split('-')[0]+“”+parseFloat(“item.label.split('-')[1]”)。toFixed(2)+“”+item.label.split('-')[2]+“””+item.label.split('-'))[3]

    “+””“”+item.label.split('-'))[4])对不起,我误解了你的问题,请发布你的Web服务代码
     response($.map(safe.d, function (item) {
    
                           return {
                               label: item.split('^')[0],
                               value: item.split('-')[0]
    
                           }