jQuery UI Widgets Forums Navigation Tree How to Get Selected JsonTree Item

This topic contains 2 replies, has 2 voices, and was last updated by  kzl 11 years, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • How to Get Selected JsonTree Item #20843

    kzl
    Member

    Hi,
    How can i get JsonTree selected item properties ?

    For example in your JsonTree Demo how can I selected tree items “value” or “text”

    var data = [
    { “id”: “2”,
    “parentid”: “1”,
    “text”: “Hot Chocolate”,
    “value”: “$2.3”
    },
    …]

    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘id’ },
    { name: ‘parentid’ },
    { name: ‘text’ },
    { name: ‘value’ }
    ],
    id: ‘id’,
    localdata: data
    };

    var dataAdapter = new $.jqx.dataAdapter(source);
    // perform Data Binding.
    dataAdapter.dataBind();
    var records = dataAdapter.getRecordsHierarchy(‘id’, ‘parentid’, ‘items’, [{ name: ‘text’, map: ‘label’}]);
    $(‘#jqxWidget’).jqxTree({ source: records, width: ‘300px’ });

    $(‘#jqxTree’).on(‘select’,function (event)
    {
    var args = event.args;
    var item = $(‘#jqxTree’).jqxTree(‘getItem’, args.element);
    //var label = item.label;
    alert(item. ?? );
    });

    How to Get Selected JsonTree Item #20899

    Dimitar
    Participant

    Hello kzl,

    Here is how to alert the value and the text:

    $('#jqxWidget').on('select', function (event) {
    var args = event.args;
    var item = $('#jqxWidget').jqxTree('getItem', args.element);
    alert("Value: " + item.value + "; Text: " + item.label);
    });

    Best Regards,
    Dimitar

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

    How to Get Selected JsonTree Item #21469

    kzl
    Member

    Hi Dimitar,
    Thank you for your help

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

You must be logged in to reply to this topic.