jQWidgets Forums

jQuery UI Widgets Forums Editors Input, Password Input, TextArea, ColorPicker, Rating, TagCloud, Loader Tag Cloud | How to get another key:value in JSON Object

This topic contains 1 reply, has 2 voices, and was last updated by  Ivo Zhulev 8 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • raj
    Participant

    Hi,

    How to get the value of another “key:value” form the JSON object during item click?

    From the below example, I would like get the value of “consumerID”. Can someone suggest me a solution?

    var data = [
            {"name": "monkeys gone wild", "rating": 35, "consumerID": '11000'},
            {"name": "i know what you did last summer", "rating": 60, "consumerID": '11001'},
            {"name": "gone with the wind", "rating": 55, "consumerID": '11002'},
            {"name": "wild hunt", "rating": 20, "consumerID": '11003'},
            {"name": "godziLLa", "rating": 50, "consumerID": '11004'},
            {"name": "lightMeUp", "rating": 80, "consumerID": '11005'},
            {"name": "lightMeUp 01", "rating": 80, "consumerID": '11006'},
            {"name": "lightMeUp 02", "rating": 80, "consumerID": '11007'}
        ];
        var source =
        {
            localData: data,
            dataType: "array",
            dataFields: [
                {name: 'name', type: 'string'},
                {name: 'rating', type: 'number'},
                {name: 'consumerID', type: 'string'}
            ]
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {});
        $('#tagCloud').on('itemClick', function(event)
        {
            var args = event.args;
            console.log('Item is clicked:\t'+args.value);
        });
        $('#tagCloud').jqxTagCloud({
            width: '80%',
            displayLimit: 20,
            source: dataAdapter,
            displayMember: 'name',
            valueMember: 'rating',
            alterTextCase: 'titleCase'
        });

    Thanks & Regards,
    Senthil


    Ivo Zhulev
    Participant

    Hi raj,

    Use the index you get from the args:

    data[args.index].consumerID

    Best Regards,
    Ivo

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.