jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree Making json tree icons bigger

This topic contains 6 replies, has 2 voices, and was last updated by  njm 11 years, 10 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Making json tree icons bigger #27874

    njm
    Member

    Hi,

    Thank you for your great plugin. I have used json tree in my page and it works good. However, icon sizes are small. I don’t know where I should write iconsize.
    my code is:

    <script type="text/javascript">
    $(document).ready(function () {
    var theme = 'summer';
    var array = @Html.Raw(
    Json.Encode(
    ((IEnumerable<WildLifePictures.Models.CTreasureTree>)ViewBag.treeLoad).Select(model => new
    {
    Id = model.Id,
    Name = model.name ,
    Parent = model.parentId,
    pAddress = model.photoAddress
    })
    )
    );
    var data = new Array(array.length);
    for (var i = 0; i < array.length; i++) {
    data[i] = {
    "id": array[i].Id,
    "parentid": array[i].Parent,
    "text": array[i].Name,
    "icon": array[i].pAddress
    }
    }
    // prepare the data
    var source =
    {
    datatype: "json",
    datafields: [
    { name: 'icon' },
    { name: 'id' },
    { name: 'parentid' },
    { name: 'text' }
    ],
    icon: 'icon',
    id: 'id',
    localdata: data
    };
    // create data adapter.
    var dataAdapter = new $.jqx.dataAdapter(source);
    // perform Data Binding.
    dataAdapter.dataBind();
    var records = dataAdapter.getRecordsHierarchy('id', 'parentid', 'items', [{ name: 'text', map: 'label' }]);
    $('#jqxTree').jqxTree({ rtl: true, source: records, width: '250px', theme: theme });
    $('#jqxTree').bind('select', function (event) {
    var args = event.args;
    var item = $('#jqxTree').jqxTree('getItem', args.element);
    $.ajax({
    url: '/WildLife/GetTreeRelatedPhotos',
    contentType: 'application/html; charset=utf-8',
    type: 'GET',
    data: { 'Id': item.id, 'Type': 'photo' },
    dataType: 'html'
    })
    .success(function (result) {
    $('#partialLoaded').html(result);
    })
    });
    });
    </script>
    <div id='jqxWidget'>
    <div style='float: right;'>
    <div id='jqxTree' style='float: right; margin-left: 60px;'>
    </div>
    </div>
    </div>

    Thank you in advance.
    I wait to hearing from you.

    Best Regards

    Making json tree icons bigger #27918

    Peter Stoev
    Keymaster

    Hi njm,

    Before loading the Tree with items, you may loop through the items to be loaded and set the “iconsize” member. “iconsize” expects a Number as value. By default it is 16.

    Best Regards,
    Peter Stoev

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

    Making json tree icons bigger #27919

    njm
    Member

    Dear Peter,

    Many thanks for your response. Could you give me an example for the loop. Where should I put the loop: Is it good to put it when I define the source. How can I define the loop?

    Best Regards,
    Najmeh

    Making json tree icons bigger #27927

    Peter Stoev
    Keymaster

    Hi njm,

    If you define the “iconsize” in the source, that will be the best option i.e to set it in the code where you set the “icon”, too.

    Best Regards,
    Peter Stoev

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

    Making json tree icons bigger #27928

    njm
    Member

    Hi Peter,

    I’ve put the iconsize in the source like this:

    for (var i = 0; i < array.length; i++) {
    data[i] = {
    "id": array[i].Id,
    "parentid": array[i].Parent,
    "text": array[i].Name,
    "icon": {iconsize:20, "icon": array[i].pAddress}
    }
    }

    Unfortunately, all icons are removed and there is no icon in tree.

    Best Regards,
    Najmeh

    Making json tree icons bigger #27930

    Peter Stoev
    Keymaster

    Hi njm,

    I did not mean exactly that. Sorry, if my answer brought that confusion.

    Sth like:

       data[i] = {
    "id": array[i].Id,
    "parentid": array[i].Parent,
    "text": array[i].Name,
    "icon": array[i].pAddress,
    "iconsize": 20
    }

    Best Regards,
    Peter Stoev

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

    Making json tree icons bigger #27933

    njm
    Member

    Dear Peter,

    Thanks a lot. Sorry for bothering you, I’ve put iconsize exactly like you, but the size of icons haven’t changed. If you could help me, I’ll me grateful.

    I wait to hearing from you.

    Best Regards,
    Najmeh

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

You must be logged in to reply to this topic.