EasyUI Forum
September 14, 2025, 06:24:42 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: reload on treegrid element  (Read 22514 times)
mzeddd
Full Member
***
Posts: 223



View Profile
« on: October 30, 2012, 12:32:48 PM »

Hi,

I'm trying to call 'reload' method on treegrid data item to load new data.
It looks like it is not working or I use it in wrong way.

I don't want to post my code here but the idea is following:

0) Create treegrid
1) Load only root elements (level 1)
2) Expand any root item (it loads data for level 2 connected to this 'root' item)
3) Do some updates for 'selected' item
4) run reload like this:
Code:
$('#myTg').treegrid('reload',id);

treegrid gets data from PHP script where in the beginning I have the following line
Code:
error_log("id=".$_POST['id']);

And returning to my steps above I have traces in error_log file:
0) N/A
1) id=  (empty) - it is OK
2) id=3 (any value) - it is OK
3) N/A
4) PHP script was not called

ERROR console (Opera) is empty.

I tried to do the same for datagrid and it was OK. The problem is in treegrid only I think.

Do I do smth wrong or it is real bug in treegrid?

//Valery
« Last Edit: October 30, 2012, 12:39:59 PM by mzeddd » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 30, 2012, 08:22:14 PM »

I suppose you want to dynamic load data when clicking the expand button. If so, please learn the tutorial below carefully.
http://www.jeasyui.com/tutorial/tree/treegrid3.php
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #2 on: October 31, 2012, 06:46:38 AM »

No, I'm using dynamic load when clicking the expand buttom on step 2

the problem is - I could not update already loaded item.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: October 31, 2012, 10:46:50 AM »

The reload method is valid for non-leaf nodes. Try selecting a non-leaf node and call reload method again, you will see the node id being posted successfully. If you only want to update a node, call update method instead.
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #4 on: November 01, 2012, 03:30:20 AM »

Sorry for stupid question but what is leaf node?

Is it line #1 or #2 on this picture?


In my case I would like to update #2 line with information from DB using "reload" method.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: November 01, 2012, 06:56:12 AM »

Line #1 is the non-leaf node(line) because it has children rows while line #2 is the leaf node(line).
Please call 'update' method to update the selected row with new information.
Code:
var row = $('#myTg').treegrid('getSelected');
if (row){
$.post('get_row.php',{id:row.id},function(data){
$('#myTg').treegrid('update',{
id:row.id,
row:data
});
});
}
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #6 on: November 03, 2012, 11:56:35 AM »

Hi stworthy,

Can you give me one move example?

I tried to modify demo/treegrid.html example with new function but I is not working as I want. It keeps old data even after I call 'update'.
Quote
function test(){
      var newData = [{
         code: '01022',
         name: 'test',
         addr: 'test',
         col4: 'test'
      }];
      $('#test').treegrid('update',{
         id:'01022',
         row:newData
      });
   }

Thanks.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 on: November 05, 2012, 07:47:22 AM »

Please correct your code.
Code:
$('#test').treegrid('update',{
id:'01022',
row:{
name:'test',
addr:'test'
}
});
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #8 on: November 05, 2012, 09:07:17 AM »

Hi stworthy.

Your last example pushed me into correct direction.

And the working code look like this:

Code:
$.post(url,{id:row.id},function(data){
$('#myTg').treegrid('update',{
id:row.id,
row:jQuery.parseJSON(data)
});
});

Thanks!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!