WelcomeForumsCommunityPre-Select items in a Remote Data Source for wijList or wijCombobox

Wijmo Team Member
ShirleyBarker posted on June 29, 2012 at 6:15 pm link

I have loaded a wijlist from a remote source and want to pre-select some of the items in the list. How is this done?

Wijmo Team Member
ShirleyBarker posted on June 29, 2012 at 6:17 pm link

Here is the code (attached).

Attachments:
  1. wijlist.txt
Answer
Wijmo Team Member
ShirleyBarker posted on July 3, 2012 at 2:30 pm link

OK, I answered my own question. Here is how I handled it:

var datasource = new wijdatasource({
reader: myReader,
data: roleArray,
loaded: function (data) {
// get items by data.items
var items = data.items;
for(var it in items) {
for(var s in selectArray) {
if(items[it].value == selectArray) {
items[it].selected = true;
}
}
}

}
});

Answer
Wijmo Team Member
xc_lw2000 posted on September 21, 2012 at 10:16 am link

It’s not work for me. Just set the selected to true?

Answer
Wijmo Team Member
Mike.Griffin posted on December 5, 2012 at 8:09 pm link

If its not working try this after you set the selection flags

$(“#list”).wijlist(“renderList”);

Then it will work. I had a situation where using “selectItems” was losing it’s selection due to some timing issue with knockout and doing this all in documentReady, thus I switched to manually setting the items.selected to true and it now works

Answer

This topic has 3 voices, contains 4 replies, and was last updated by  Mike.Griffin 172 days ago.

You must be logged in to reply to this topic.