Prime UI tree lazy loading

jQuery UI Widgets
Post Reply
bozhorasan
Posts: 3
Joined: 23 Jul 2014, 08:35

23 Jul 2014, 08:48

Greetings, I'm new to the forum and prime ui.
I'm trying to create a lazy tree.
In the documentation, nodes are loaded from a URL providing rest based service.
I need to load nodes lazily from an ordinary javascript function (not from a URL). The reason is nodes are created dynamically/programmatically by the user, I do not have a chance of getting nodes from a server service.
Is this possible using prime ui? Can you post an example?
Thanks in advance.

pmc34
Posts: 22
Joined: 16 Nov 2013, 16:00
Location: France
Contact:

24 Jul 2014, 23:39

Hi,

You can't add or remove tree nodes dynamically because no method exists in the puitree for this purpose.

The only way I found is to destroy and recreate the puitree each time its structure is updated, but it's only suitable if your tree does not contain too much nodes.

Example of puitree initialization from a javascript variable :

Code: Select all

$('#mytree').puitree({  
			lazy: false,
			nodes: function(ui, response) {                          
				var data = [{"label":"Node 0","data":"0","children":[{"label":"Node 10","data":"10"}]}];
				response.call(this, data);  
			}  
		});
Exemple of puitree widget removal :

Code: Select all

$('#mytree').remove();
Regards,

Pascal
Last edited by pmc34 on 02 Aug 2014, 18:23, edited 1 time in total.

bozhorasan
Posts: 3
Joined: 23 Jul 2014, 08:35

25 Jul 2014, 09:28

Merci Pascal.
The last line worked as response.call(this,data,ui.node) in my end, for your information.

qaism123
Posts: 1
Joined: 09 Oct 2014, 07:29

09 Oct 2014, 07:32

Hi Stephan,

I use the jQuery function "serializeArray()" applied to the form element containing the puilistbox widget to get its selected values.

Hoping it will be helpful.

Pascal
aliiiiii

Post Reply

Return to “PrimeUI”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests