EasyUI Forum
March 29, 2024, 01:54:56 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: treegrid dynamic load and grid refresh  (Read 25900 times)
Onegin
Newbie
*
Posts: 11


View Profile
« on: July 07, 2011, 01:30:23 PM »

I use treegrid component and because of the number of records, i load branches dynamically via ID reference.
Problem is, that when I hit refresh, the appended id in uri is sent to server and it returns only that portion of records that is supposed to be that branch data...
My question is how can I load data dynamically to the treegrid and be able to refresh the whole grid without last used ?id=foo beying appended to grid url.
Logged
Onegin
Newbie
*
Posts: 11


View Profile
« Reply #1 on: July 08, 2011, 02:02:30 AM »

I actually sorted this out, hopefully it can help someone else:

if you use lazy data load to branches of a treegrid, the URL property will be poluted by queryParams, such as
id = id of selected row
pageNumber = from pagination (if used)
pageSize = from pagination (if used)
this is everything perfectly ok, till you decide to reload the whole grid (e.g. after you append a new row). The poluted data URL is used to fetch data from server, but with appended queryParams the server cannot really distinguish whether to send all recordset or only branch data. For that reason you have to clear things out.

Used this snippet to reload grid:
Code:
var params = $('#tt').treegrid('options').queryParams;
if(params.id){delete params.id};
$('#tt').treegrid('reload');

Note, that I preserved all other params except id, as they will not interfere with server side logic.
also note, that pagination object must be handled separately:

I added this event function:
Code:
onBeforeRefresh:function(pageNumber, pageSize){
            var params = $('#tt').treegrid('options').queryParams;
            if(params.id){delete params.id};
        }

If there is a smarter way how to handle this kind of a problem, I will certainly appreciate to hear about it. Thanks.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: July 12, 2011, 12:21:28 AM »

Update to the version 1.2.4 and you can simply call 'reload' method, don't need to delete the 'id' property.
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!