Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Version 4.0.0: OnExpand Event
25/05/2011
08:56
Avatar
Chico80
Member
Members
Forum Posts: 3
Member Since:
25/05/2011
sp_UserOfflineSmall Offline

Hello,

is it planned to include an event "OnExpand" in future?

I load the nodes into the tree using ajax requests to an ASP.NET Server, and in order to
load the child-nodes on demand I need this event.

Greets

Chico80

25/05/2011
11:05
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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 

25/05/2011
15:06
Avatar
Chico80
Member
Members
Forum Posts: 3
Member Since:
25/05/2011
sp_UserOfflineSmall Offline

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

25/05/2011
16:02
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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

26/05/2011
17:22
Avatar
Chico80
Member
Members
Forum Posts: 3
Member Since:
25/05/2011
sp_UserOfflineSmall Offline

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

27/05/2011
10:44
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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 

28/03/2012
09:44
Avatar
chait
New Member
Members
Forum Posts: 2
Member Since:
27/03/2012
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information