0

I have an issue. I need to populate one dropdown with a list of items. The way I am currently doing it is to do a select top 500, but i really need all the items in there and there could be 1000 or more. Below is a paste of the amount of data im trying to send back when the site crashs.

http://pastebin.com/d5xjDvUR

Jquery:

 $.ajax({
    type: "POST",
    url: "WebService.asmx/GetFinish1",
    data: '{' +
                    'Item:"' + item + '"' +
               '}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {
        //$("#item").val(msg);
        var data = jQuery.parseJSON(msg);
        if (!data.error) {
            $.each(data, function (d) {
                var areaText = $('#notes').val();

                if (data[d].Dropdown == "Finish1") {
                    if (data[d].Value != "") {
                        $("<option>").attr("value", data[d].id).text(data[d].Value).appendTo($('#dropFinish1'));
                    }
                }
                if (data[d].Dropdown == "Finish2") {
                    if (data[d].Value != "") {
                        $("<option>").attr("value", data[d].id).text(data[d].Value).appendTo($('#dropFinish2'));
                    }
                }
                if (data[d].Dropdown == "Length") {
                    if (data[d].Value != "") {
                        $("<option>").attr("value", data[d].id).text(data[d].Value).appendTo($('#dropLength'));
                    }
                }
                if (data[d].Dropdown == "Unit") {
                    if (data[d].Value != "") {
                        $("<option>").attr("value", data[d].id).text(data[d].Value).appendTo($('#dropUnit'));
                    }
                }
                if (data[d].Dropdown == "Notes") {
                    if (data[d].Value != "") {
                        $('#notes')[0].value = areaText + data[d].Value;
                    }
                }
            });
2
  • Have you considered auto-complete instead of a drop down list? Also, you can cut down on the amount of data transferred by trimming property names, like 'Dropdown'->dd. Commented Feb 1, 2012 at 16:51
  • How are you creating the dropdown, in javascript? What's the code like? Try building the select html string and setting the innerHTML of the container because it is known to be faster than creating DOM elements.
    – Roland Mai
    Commented Feb 1, 2012 at 16:51

1 Answer 1

1

I would argue that no one wants to dig through 1000+ items in a drop down unless it's some kind of auto completing drop down that you can type hints into. Even then it sounds like there is simply too much data. I would focus on trying to divide the dataset into pieces by getting the user to enter some information. If you can get a couple of piece of information to use to make the query results a 10th of that size you're in good shape. That's how I've solved that problem before.

Not the answer you're looking for? Browse other questions tagged or ask your own question.