Nakres
Nakres

Reputation: 1612

listbox loads so slow using knockout

I have a group of radio buttons a dropdownlist and a list box. When the use changes dropdownlist listbox gets filled up based on radio buttons.(I have other parameters too). It takes 2 mins for 6.000 records to load listbox. Is there any other faster way? Would it be faster if I fill up listbox in controller using dropdown change event?if yes how can I do that?

   $.getJSON('GetRecipients', { state: state, distrChan: valueOfDistrChan, isactive: valueOfrdoActTer, groups: groups, mktGroup: valueOfMarkGrp, subjectID: subjectID }, function (data) {
        var result = $.parseJSON(data);
        $.each(result, function (i, item) {
            self.recipientList.push(item);
        });

    });

view:

 @Html.ListBoxFor(model => model.SelectedRecipients, new MultiSelectList(new[] { "" }), new { @class = "form-control", @size = 11, data_bind = "options: recipientList,optionsValue:function(i) {return i.ID}, optionsText: function(i) {return i.LastName +', '+ i.FirstName}" })

Upvotes: 1

Views: 106

Answers (1)

Francis Nepomuceno
Francis Nepomuceno

Reputation: 5085

If result is an array, try assigning it to recipientList ?

var result = $.parseJSON(data);
self.recipientList(result);

Upvotes: 1

Related Questions