Forum
11:05
10/08/2009
Hello Chico80,
what you asked is already the default behavior of the Tree Grid. If the user expanding the tree node it will be additional request to the server will be send where three additional parameters will be send: nodeid, parentid and n_level (see the documentation). So if the server response on such requests with the child notes all will works like you as want.
You should be carefull on the server to response with the correct data (see this answer which describes which effects you can has on wrond response). If you want you can mark some tree nodes as "static", so only the previous loaded data about the child nodes will be used. To do this you should just include loaded:true property for the tree node.
Best regards
Oleg
15:06
25/05/2011
Hello Oleg,
thanks for your answer, I know this. functionality.
But I do not have the option to pass an URL, I have to query my data by an jQuery AJAX Request.
I pass the parent ID and get some JSON data. On client side I am updating the data array.
It is working if I use the onRowSelected event, but I do not retrieve an event clicking on the expand symbol.
I hope you can understand my problem, it is by design of our complete architecture.
Greetz
Chico
16:02
10/08/2009
Hello Chico,
Sorry, but I don't understand what you do. Which "data array" and how you update? What you do inside of onSelectRow event (onRowSelected event not exist)?
I hate if one explains about the program instead of just posting the code. The code say what you do and the explanation say only what you want to do.
There are many possibility to solve you problem. For example you can use postData parameter to send edditional (also absolutely dynamic) informations to the server of you can change any time the value of url parameter of jqGrid. The event onCellSelect is one more event which can be helpful for you. If all this gives you not what you need you can find "div.treeclick" elements unbind the original onclick event handler and bind you own one (see here).
The main problem is that I don't really understand your problem and so it's difficult for me to recommend you somthing, because some more simple thing probably can solve your problem.
Best regards
Oleg
17:22
25/05/2011
Example code:
I have a js class ClientExtendedgrid:
function ClientExtendedTree() {
var _ = this;
this.jqGridDiv = null;
... //More Properties
this.Init = function() {
this.jqGridDiv.jqGrid(
{
datatype: "local",
data: this.Data,
colNames: this.ColumnNames,
colModel: this.ColumnModel,
height: 'auto',
sortname: this.SortName,
treeGrid: true,
treeGridModel: 'adjacency',
treedatatype: "local",
ExpandColumn: this.ExpandColumn,
caption: "Sample Tree View Model",
altRows: true,
autowidth: this.AutoWidth,
forceFit: this.ForceFit,
shrinkToFit: this.ForceFit,
rowNum: this.RowsPerPage,
rowList: this.RowList,
ExpandColClick: true,
onSelectRow: function(id) {
.....
},
onCellSelect: function(rowid, iCol, cellcontent, e) {
}
});
}
.... //More Funktions
}
The function onSelectRow hast the following content:
setTimeout(function() {
var recordInfo = _.jqGridDiv.getLocalRow(id);
if (!recordInfo.loaded) {
var param = { 'key': _.Key, 'id': id };
GlobalFunctions.LoadJSONDataAsync('[Some .NET Assembly]',
'[.NET Class]',
'[Method to query JSON data]',
param,
function(result) { //OnSuccess
var data = JSON.parse(result);
for (var i = data.length - 1; i >= 0; i--) {
for (var j = 0; j < _.Data.length; j++) {
if (_.Data[j].id == data[i].parent) {
_.Data.splice(j + 1, 0, data[i]);
j = _.Data.length;
}
}
}
_.Clear();
_.jqGridDiv[0].addJSONData({
total: 1,
page: 1,
records: _.Data.length,
rows: _.Data
});
});
}
If I had an event onExpand I could load the data beofre expanding, so the data is loaded when I click into the row,
but not when I click the expand symbol.
It is pretty much code I posted, that´s why I did not do this in my previous post, but I hope now you can understand me!
Greets
Chico
10:44
10/08/2009
Ohhh, Chico!!!
It seems to me you are master to make simple things complex. Sorry!
The problem is that Tree Grid is implemented to support only remote data: datatype:"json" and treedatatype: "json". The "local" datatype is not full supported. For example you can't fill the tree grid using datatype:"local", treedatatype: "local" and data:this.Data. There are a workaround if you use addJSONData, but it is the workaround only and not real the main way implemented by design.
So I recommend you to change your code and use the url parameter of jqGrid. jqGrid will get asynchronous requests to the server and fill the jqGrid contain with the server resonse. In the case you will have no problems and on the node expanding a new request to the server with additionally parameters, which describes the current node, will be send to the server.
If needed you can use functions in the jsonReader.
Best regards
Oleg
09:44
27/03/2012
Hi Oleg,
Even I have the similar problem. I am using local data. In my case…When I click on expand/collapse icon, first I need to send a request to server, then refresh treegrid dataset with the server's response and then call treeGrid's expandRow.
How can I call a method(I mean override treeGrid's expandRow method) which does the abve things before calling treeGrid's expandRow method?
Thanks in advance,
Chaitu
Most Users Ever Online: 715
Currently Online:
39 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66