Nadya Posted June 29, 2020 Share Posted June 29, 2020 Hi! I heed help again Problem is in displaying the selected dbtreegrid node which was found in underlying dataset by Locate(...) method. I have two TUniDBTreeGrid components on form. GridStructure shows structure of nodes with two levels, GridData should display info for selected node in GridStructure. So when I use Locate to find node in manually or programmatically collapsed GridStructure, dataset position is correct and info in GridData is OK, but the selection in GridStructure displays incorrectly. I wrote "expandSelectedNode" method (as you advised me): function beforeInit(sender, config) { var me = sender; me.expandSelectedNode = function() { var _selection = me.getSelectionModel().getSelection()[0]; if (_selection) { _selection.cascadeBy(function(node) { node.expand(); }); sender.ensureVisible(sender.getSelectionModel().getSelection()[0]); } }; } And after locating record I use this code: grdStructure.JSInterface.JSCall('expandSelectedNode', []); grdStructure.JSInterface.JSCode('Ext.defer(function(){'#1'.ensureVisible('#1'.getSelection()[0])}, 200);'); But is doesn't helph in some cases. I've made a testcase to demonstrate my problem. TreeGridLocationTestCase Please, do following: 1) Select node "Node1" in GridStructure, press button "Refresh info" below - Node1 is selected in GridStructure, GridData shows info for Node1 = CORRECT 2) Expand Node1, select child node "Node1_13" in GridStructure, press button "Refresh info" - Node1_13 is selected in GridStructure, GridData shows info for Node1_13 = CORRECT 3) Select Node1_13, press button "RefreshStructure" higher, press button "RefreshData" below - tree is collapsed, selection is not visible in GridStructure, GridData shows info for Node1_13 = INCORRECT 4) Expand Node1 in GridStructure, type text "Node1_14" in the edit box on the top of form, press button "Search structure node" - node "Node1_14" is found and selected, GridData shows info for Node1_14 = CORRECT 5) Collapse tree in GridStructure, type text "Node1_15" in the edit box on the top of form, press button "Search structure node" - tree is collapsed, selection is not visible in GridStructure, GridData shows info for Node1_15 = INCORRECT Please, "kick me out" of this swamp, somebody! Thank you! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 29, 2020 Share Posted June 29, 2020 I will try to analyze. 1 Quote Link to comment Share on other sites More sharing options...
Nadya Posted June 29, 2020 Author Share Posted June 29, 2020 1 hour ago, Sherzod said: I will try to analyze. Thank you! I'll be hopefully waiting... Quote Link to comment Share on other sites More sharing options...
Nadya Posted July 1, 2020 Author Share Posted July 1, 2020 On 6/29/2020 at 5:55 PM, Nadya said: Thank you! I'll be hopefully waiting... And I'm still here, waiting for your magic and wisdom :-) Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 1, 2020 Share Posted July 1, 2020 4 hours ago, Nadya said: And I'm still here, waiting for your magic and wisdom :-) Hello Nadya, Magical seasonings are over But, also try this approach: 1.grdStructure function beforeInit(sender, config) { var me = sender; me.expandSelectedNode = function() { var _selection = me.getSelectionModel().getSelection()[0]; if (_selection) { _selection.cascadeBy(function(node) { node.expand(); }); sender.ensureVisible(sender.getSelectionModel().getSelection()[0]); } }; sender._locate = function(id) { var node = sender.getStore().getRootNode().findChild('1', id, true); var pnode = node.parentNode; if (pnode) { pnode.expand(); while (pnode.parentNode) { pnode = pnode.parentNode; } sender.getSelectionModel().select(node, true); sender.ensureVisible(sender.getSelectionModel().getSelection()[0]); } } } 2. RefreshStructure ... if cdsStructure.Locate('ID', ID, []) then begin grdStructure.JSInterface.JSCallDefer('_locate', [ID], 500); //grdStructure.JSInterface.JSCall('expandSelectedNode', []); //grdStructure.JSInterface.JSCode('Ext.defer(function(){'#1'.ensureVisible('#1'.getSelection()[0])}, 200);'); end; ... 1 Quote Link to comment Share on other sites More sharing options...
Nadya Posted July 1, 2020 Author Share Posted July 1, 2020 Thank's for your help! I've tried this - in my test project it works perfectly, but in the main project StructureGrid selects the top node after "Locate" StructureGrid in the main project refreshing takes much more time and the tree contains much more nodes. So if I encrease the interval of JSCallDefer upto 1000 (for example) - may it help? Quote Link to comment Share on other sites More sharing options...
Nadya Posted July 1, 2020 Author Share Posted July 1, 2020 17 minutes ago, Nadya said: StructureGrid in the main project refreshing takes much more time and the tree contains much more nodes. So if I encrease the interval of JSCallDefer upto 1000 (for example) - may it help? I've just tried to encrease even upto 4000 - doesn't help Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 1, 2020 Share Posted July 1, 2020 1 hour ago, Nadya said: I've just tried to encrease even upto 4000 - doesn't help Sorry, the decision didn’t help you. Maybe there is an easier way, I need to analyze more. Quote Link to comment Share on other sites More sharing options...
Nadya Posted July 1, 2020 Author Share Posted July 1, 2020 4 minutes ago, Sherzod said: Sorry, the decision didn’t help you. No, I'm really appreciate your help. As I said before - in test project it works great. But the main project is big and complicated (I'm moving it from desktop to web version) so I'm sure I do something wrong myself. 6 minutes ago, Sherzod said: Maybe there is an easier way, I need to analyze more. You're so kind! Thank you very much! I'll be waiting... Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 8, 2020 Share Posted July 8, 2020 On 7/1/2020 at 11:11 AM, Sherzod said: 2. RefreshStructure ... if cdsStructure.Locate('ID', ID, []) then begin grdStructure.JSInterface.JSCallDefer('_locate', [ID], 500); //grdStructure.JSInterface.JSCall('expandSelectedNode', []); //grdStructure.JSInterface.JSCode('Ext.defer(function(){'#1'.ensureVisible('#1'.getSelection()[0])}, 200);'); end; ... On 7/1/2020 at 2:00 PM, Nadya said: I've just tried to encrease even upto 4000 - doesn't help Hello Nadya, Can you try this approach?: ... if ID > 0 then begin grdStructure.JSInterface.JSCall('getSelectionModel().deselectAll', []); if cdsStructure.Locate('ID', ID, []) then begin grdStructure.JSInterface.JSCode(#1'.loadlistener=()=> {'#1'._locate('+ ID.ToString +'); '#1'.store.removeListener("load", '#1'.loadlistener)};'#1'.store.addListener("load", '#1'.loadlistener);'); //grdStructure.JSInterface.JSCallDefer('_locate', [ID], 500); //grdStructure.JSInterface.JSCall('expandSelectedNode', []); //grdStructure.JSInterface.JSCode('Ext.defer(function(){'#1'.ensureVisible('#1'.getSelection()[0])}, 200);'); end; end else ... 1 Quote Link to comment Share on other sites More sharing options...
Nadya Posted July 8, 2020 Author Share Posted July 8, 2020 1 hour ago, Sherzod said: Hello Nadya, Can you try this approach?: ... if ID > 0 then begin grdStructure.JSInterface.JSCall('getSelectionModel().deselectAll', []); if cdsStructure.Locate('ID', ID, []) then begin grdStructure.JSInterface.JSCode(#1'.loadlistener=()=> {'#1'._locate('+ ID.ToString +'); '#1'.store.removeListener("load", '#1'.loadlistener)};'#1'.store.addListener("load", '#1'.loadlistener);'); //grdStructure.JSInterface.JSCallDefer('_locate', [ID], 500); //grdStructure.JSInterface.JSCall('expandSelectedNode', []); //grdStructure.JSInterface.JSCode('Ext.defer(function(){'#1'.ensureVisible('#1'.getSelection()[0])}, 200);'); end; end else ... Hi Sherzod! Thank you very much, it works!!!! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.