jQWidgets Forums

jQuery UI Widgets Forums Lists DropDownList selectItem not working with DataAdapter

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  augustoMoreira 8 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • selectItem not working with DataAdapter #87129

    augustoMoreira
    Participant

    I load a dynamic list of animals from server, according to the selected animal owner dropdown. And then I need to select the corresponding animal using the animal_id stored on appointment

    my dropDown:

        $("#animal").jqxDropDownList({
            source: animalAdapter,
            displayMember: "name",
            valueMember: "animal_id",
            width: "345px",
            height: "20px",
            filterable: true,
            filterPlaceHolder: "Buscar",
            placeHolder:"-- Novo Animal --"
        });

    my source and adapter:

    
    var animal = {
    	datatype:'json',
    	datafields:[
    		{name:'name',type:'string'},
    		{name:'animal_id',type:'int'}
    	],
    	url:'list_animals',
    	async:false
    };
    var animalAdapter = new $.jqx.dataAdapter(animal,{
    	formatData: function(data) {
    			data.owner_id = getSelectedOwner();
    			return data;
    		},
    
    });
    

    my selectItem code:

    		animalAdapter.dataBind();
        $("#animal").jqxDropDownList('selectIndex', appointmentData.animal_id );
    

    my server data response:
    [{animal_id: 9773, name: "Nina"}]

    selectItem not working with DataAdapter #87203

    augustoMoreira
    Participant

    Any help? it seems a bug, when i log the itens(with getItems) all itens have the field value as undefined, but if i remove ‘animal_id’ from the datafields, the value is filled with the name.
    what i’m doing wrong?

    selectItem not working with DataAdapter #87213

    Peter Stoev
    Keymaster

    Hi augustoMoreira,

    selectIndex expects a specific zero-based index of an item. 0 – selects a first item, 1 the second and so on. In the provided code, you try to select by ID which is not possible with selectIndex method.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    selectItem not working with DataAdapter #87230

    augustoMoreira
    Participant

    sorry, i pasted an older code.
    with selectItem the code still does not work

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.