Categories | Question details Back To List | ||||||||
DhtmlxGrid - how to return all group values Hi. I am having problems when trying to use the "onGroupStateChanged" event (http://www.dhtmlx.com/dhxdocs/doku.php?id=dhtmlxgrid:event_ongroupstatechanged). What I am trying to do is, when such event occurs, get the clicked group, expand it and collapse all others groups. The problem is that when I try to use the "value" or "state" parameter, I always get a "undefined" value. ------- Code excerpt --------- grid1.attachEvent("onGroupStateChanged", function(value, state){ grid1.collapseAllGroups(); grid1.expandGroup(value); }); ------- End of Code excerpt --------- (I know the code needs improvement due to the way event will be triggered) Does the method works as expected ? Is there anything that I am not doing correctly ? Answer posted by dhxSupport on Nov 05, 2009 09:55 You can use following code: mygrid.attachEvent("onGroupStateChanged", function(value,state){ if (this._go_away) return; this._go_away = true; mygrid.collapseAllGroups(); mygrid.expandGroup(value); this._go_away = false; }); Answer posted by Bux on Nov 05, 2009 10:46 I think I was not clear on my question. The problem was not exactly with the algorithm, but the event parameters. It seems that "value" parameter is empty when reaches the event. For a sample code: mygrid.attachEvent("onGroupStateChanged", function(value,state){ alert(value); }); When I expand/collapse a group, the alert is displayed with the word "undefined" on it. I also looked at this question (http://www.dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=5445&ssr=yes&s=ongroup%20event) which contains the following answer from support: "There is an inner event "onGroupStateChanged", which occurs when some group closed|opened, but it doesn't provide any useful parameters" Also, the sample code you put on the answer is not giving me the behavior I expect (which I think is because the parameter 'value' is empty when it reaches the line "mygrid.expandGroup(value);". The same applies to 'state' parameter). Am I missing anything ? Answer posted by dhxSupport on Nov 06, 2009 08:24 What version of dhtmlxGrid do you use? We tested this code at the 2.5 version and it works well. "onGroupStateChanged" event has useful parameters since dhtmlxGrid 2.5 Answer posted by Bux on Nov 06, 2009 08:41 Hi. The version I am using is 2.1 //v.2.1 build 90316 Does "onGroupStateChanged" event parameters work on this 2.1 build version ? Answer posted by Stanislav (support) on Nov 09, 2009 06:10 Updated js file was sent by email, pleas try to use it instead of the original one. Answer posted by Bux on Nov 10, 2009 08:16 Hi, Stanislav. I've tried using the js file you sent me, but it did not change anything. I am still getting and 'undefined' when try to use 'value' or 'state' parameter from 'onGroupStateChanged' event. There is an attached file containing a sample that I used to test the 'onGroupStateChanged' event. Notice the last two lines of the event: I used an "alert()" method in order to get the content of "value" and "state" parameter (which is always is displayed as "undefined"). Also, when running such sample code on Firefox (3.5), I get the following error on my "error console": Error: this._groups[val] is undefined Source File: file:///C:/Users/user/Desktop/dhtmlxgridtest/test/codebase/ext/dhtmlxgrid_group.js Line: 30 Should I upgrade to 2.5 version ? Will it work on this new version ? It is important to mention that my company has a commercial license of dhtmlx suite. Thanks. Answer posted by Bux on Nov 10, 2009 08:31 Hi, Stanislav. I've tried using the js file you sent me, but it did not change anything. I am still getting and 'undefined' when try to use 'value' or 'state' parameter from 'onGroupStateChanged' event. There is an attached file containing a sample that I used to test the 'onGroupStateChanged' event. Notice the last two lines of the event: I used an "alert()" method in order to get the content of "value" and "state" parameter (which is always is displayed as "undefined"). Also, when running such sample code on Firefox (3.5), I get the following error on my "error console": Error: this._groups[val] is undefined Source File: file:///C:/Users/user/Desktop/dhtmlxgridtest/test/codebase/ext/dhtmlxgrid_group.js Line: 30 Should I upgrade to 2.5 version ? Will it work on this new version ? It is important to mention that my company has a commercial license of dhtmlx suite. Thanks. Attachments (1)
Answer posted by Stanislav (support) on Nov 10, 2009 08:36 a) The js file, in the provided sample, is old version which will not work. You need to use the file which was sent by email ( or just update to latest dhtmlx 2.5 ) b) After updating js file, you need to update your code mygrid.attachEvent("onGroupStateChanged", function(value, state) { if (this._go_away) return; this._go_away = true; mygrid.collapseAllGroups(); mygrid.expandGroup(value); code marked in bold is changed After such updates the sample starts to behave correctly. Answer posted by Bux on Nov 10, 2009 08:50 Thanks for your quick support/answer ! I may have really used the old version of js file. The code I sent was a test I made but forgot to change it back (from 'state' to 'value'). Sorry for my mistaken (I was working with a lot of different set of samples). Anyway, it is working as expected right now. Thank you. |