Wednesday, 13 February 2019

jQuery UI autocomplete values not getting selected after selection from mouse

I have created a functionality of autocomplete using jquery. It works perfectly fine but for ex:

Whenever I type a text and and select the values from the list using mouse, it gets selected for the first time but if I again type and select the list. The values dont get selected.

Below is my code. I am not able to get why its not wroking.

$(document).ready(function () {
$('#txtAssignVendor').autocomplete({
    source: AppConfig.PrefixURL + 'VendorData.ashx',
    position: {
        my: "left bottom",
        at: "left top",
    }
});});

UPDATE

And in Vendor.ashx file below is the code which I use

public void ProcessRequest(HttpContext context)
    {
        try
        {
            //DataTable dt = new DataTable();
            string term = context.Request["term"] ?? "";
            List<string> VendorNames = new List<string>();
            string connString = ConfigurationManager.ConnectionStrings["ConnAPP_NEIQC_PLNG"].ConnectionString;

            using (OracleConnection conn = new OracleConnection(connString))
            {
                OracleCommand cmd = new OracleCommand("", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = ConfigurationManager.AppSettings["PackageName"].ToString() + ".GET_VENDOR_NAME";
                cmd.Connection = conn;

                cmd.Parameters.Add(new OracleParameter { ParameterName = "P_VENDORNAME", Value = term, OracleDbType = OracleDbType.NVarchar2, Direction = ParameterDirection.Input });

                cmd.Parameters.Add(new OracleParameter
                {
                    ParameterName = "TBL_DATA",
                    OracleDbType = OracleDbType.RefCursor,
                    Direction = ParameterDirection.Output
                });

                if (conn.State != ConnectionState.Open) conn.Open();
                OracleDataAdapter da = new OracleDataAdapter(cmd);

               // da.Fill(dt);

                OracleDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    VendorNames.Add(dr["VENDORNAME"].ToString());
                    //VendorNames.Add(string.Format("{0}-{1}", dr["VENDOR_CODE"], dr["VENDOR_NAME"]));
                }
            }

            JavaScriptSerializer js = new JavaScriptSerializer();
            context.Response.Write(js.Serialize(VendorNames));
        }
        catch (Exception ex)
        {                
            throw;
        }    
    }



from jQuery UI autocomplete values not getting selected after selection from mouse

No comments:

Post a Comment