jQWidgets Forums
jQuery UI Widgets › Forums › Navigation › Tree › Making json tree icons bigger
Tagged: javascript treeview, jqxtree
This topic contains 6 replies, has 2 voices, and was last updated by njm 11 years, 10 months ago.
-
Author
-
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
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 StoevjQWidgets Team
http://www.jqwidgets.com/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,
NajmehHi 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 StoevjQWidgets Team
http://www.jqwidgets.com/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,
NajmehHi 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 StoevjQWidgets Team
http://www.jqwidgets.com/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 -
AuthorPosts
You must be logged in to reply to this topic.