Categories | Question details Back To List | ||
Keep selected row after grid refresh Is there an easy way to keep a row selected in a grid after the grid contents are refreshed? I am calling selectRow() on the grid after the refresh but it's not working. (Interestingly, if I have an alert statement and click 'ok' before I call selectRow() it does work.) Answer posted by Alex (support) on May 18, 2009 07:23 selectRow() should be added after xml is completely loaded. The 4th parameter of the updateFromXML method is function that is called after xml loading: grid.updateFromXML(url,insert_mode,del_mode,function(){ grid.selectRow(...) }) Answer posted on May 18, 2009 07:52 I am not using an update function but rather: grid.clearAll(); This is not working unless I have an alert() statement. Does the click of the alert execute some code that makes it work? Answer posted by Alex (support) on May 18, 2009 08:13 In this case the same approach can be used: grid.clearAll(); function doAfterLoading(){ } Answer posted on May 18, 2009 08:22 Why does grid.clearAll(); not work? Why do I have to do it within the load function? Answer posted by Support on May 18, 2009 08:28 Loading is async., load command just start loading process , so next command will be executed while data still in loading process. When second parameter of load command used - code inside it will be executed exactly after data loading Answer posted on May 18, 2009 09:07 I am doing what you suggested but it isn't working. I am getting the feeling that it is still executing before the grid is finished loading, because when I print out grid.getRowIndex(row) in doAfterLoading() it is undefined. The following is the code: grid.clearAll(); this.doAfterLoading = function (grid, row) { alert(grid.getRowIndex(row)); //this prints 'undefined'
Answer posted by Alex (support) on May 18, 2009 09:14 Not exactly .... Try to use the following: grid.load(url, this.doAfterLoading, "xml"); instead of grid.load(url, this.doAfterLoading(grid, row), "xml"); Answer posted on May 18, 2009 09:18 The function requires those parameters (grid, row) in order to execute properly? Answer posted by Alex (support) on May 18, 2009 09:23 The second parameter of the load method is on loading end event handler. It isn't possible to pass custom parameters into it. doAfterLoading(){ ... } Answer posted on May 18, 2009 09:23 This still did not work: grid.clearAll(); this.doAfterLoading = function () { Answer posted by Alex (support) on May 18, 2009 09:25 Well.. once again... Please, be attentive grid.load(url, this.doAfterLoading, "xml"); there isn't (). Answer posted on May 18, 2009 09:34 Sorry, I posted that before I got your answer. It works as an inline function. Thanks. |