JQuery AutoComplete with Sequence Selection

1

I have a text field in the database sql server varchar (MAX).

I'm using JQuery and C # to do an autocomplete.

This is populated by an "autocomplete.ashx" file called by jqyery.

My field in the database is a string that is dynamically mounted at levels that are divided by the special character "\".

String example (full name field): "first level \ second \ third \ fourth \ fifth"

The table is basically composed of the following fields: Id, FullName, Level

Given from scenario what I need is that autocomplete work as follows:

When clicked without typing nothing appears only the first level records, when the first level selection is made automatically the autocomplete appears with the second level options within the first level, when the second level is selected the third level and so on.

Currently it's working as a normal autocomplete, picking up any part of the complete string.

public class ContaAutoComplete : IHttpHandler, IReadOnlySessionState
{
    public void ProcessRequest(HttpContext context)
    {
        var nomeCompleto = context.Request.QueryString["term"];

        var contas = Conta.ObterVarios(idCliente: MySession.Cliente.Id, nomeCompleto: nomeCompleto)
            .Select(x => new
            {
                value = x.NomeCompleto,
                label = x.NomeCompleto
            });


        using (var jsonWriter = new JsonTextWriter(context.Response.Output))
        {
            var serializer = new JsonSerializer();

            serializer.Serialize(jsonWriter, contas);
        }
    }

    public bool IsReusable
    {
        get
        {
            return true;
        }
    }
}

    <script type="text/javascript">

        $(function () {

            $("#<%=txtContaAutoComplete.ClientID%>").autocomplete({
                source: 'ContaAutoComplete.ashx',
                minLength: 0
            }).focus(function () {

                $(this).autocomplete("search", "");
            });
        });

    </script>
    
asked by anonymous 05.10.2015 / 22:42

0 answers