Categories | Question details Back To List | ||
Add Row and Focus Into the Row I have a dhtmlXGridObject and I am calling: tblGrid.addRow(nextNewIndex, " ,,,,,", 0); tblGrid.selectRow(nextNewIndex, false, false, true); I expected that this would select the added row and change the focus of the cursor to the first cell of this newly added row, but it is not selecting the row or focusing to the row. What else do I need to do? Answer posted by dhxSupport on Apr 24, 2009 06:41 Please check this article http://dhtmlx.com/docs/products/kb/index.shtml?cat=recent&q=7285 Answer posted on Apr 24, 2009 07:15 This selects the new row but does not put the focus/cursor in the first cell of the row. Answer posted by dhxSupport on Apr 24, 2009 07:47 If you are adding row by pressing on some button you should cancel bubble for "onclick" event: <button onclick="(arguments[0]||window.event).cancelBubble=true;addRow()">addRow</button> Answer posted on Apr 24, 2009 07:55 Still, the cursor is not in the selected cell... Answer posted on Apr 24, 2009 08:14 Can you explain a little how your code works (why we have to use cancelBubble) Answer posted by Alex (support) on Apr 25, 2009 00:40 When you click somewhere on the page, the grid loses focus. Bubbling must be canceled to prevent that. Answer posted on Apr 27, 2009 06:28 When I call tblGrid.selectCell(tblGrid.getRowIndex(nextNewIndex), 0, false, false, true, true).focus(); I am getting an error that the tblGrid... is null or not an object but I know it exists? Answer posted by Support on Apr 27, 2009 10:05 >>When I call tblGrid.selectCell(tblGrid.getRowIndex(nextNewIndex), 0, false, false, true, true).focus(); what is the purpose of "focus"command at the end ? The next command is enough to select cell and move selection focus to it, you need not call any extra commands on its result tblGrid.selectCell(tblGrid.getRowIndex(nextNewIndex), 0, false, false, true, true) Answer posted on Apr 27, 2009 10:13 The cell is not selected when I do not call focus() Answer posted on Apr 27, 2009 10:14 When I call tblGrid.cellByIndex(0, 0); I get the javascript error _childIndexes is null or not an object Answer posted by dhxSupport on Apr 27, 2009 12:13 Please contact support@dhtmlx.com and provide sample where we can reproduce this issue. Answer posted by C. Bernstein on May 05, 2009 08:15 Can you please explain why we need to use cancelBubble? Exactly what event isn't getting/is getting fired that is making things not work as they should? Is the addRow() or selectCell() relying on an onClick event? I am having trouble finding anything in the grid documentation. Is the following happening? "I think the tableGrid.selectCell() will not work unless the tableGrid is in focus. Normally when you click on a button (like Add Local Row) the grid will get an onblur event (when it loses focus and the button gets focus). I think when you add the cancelBubble it prevents the onblur event from happening. "
Answer posted by Alex (support) on May 06, 2009 06:03 Hello, grid editor is always closed by click on the page - this is correct behavior. Please, try to open any grid sample, open grid editor and click somewhere - the editor is closed. The same is for button click. You click on button - the editor is closed. One more experiment - try to call selectCell method without click, for example, after xml loading: grid.loadXML("some.xml",function(){ grid.selectCell(1, 0, false, false, true, true); }) The editor will be opened. So, you need to use cancelBubble in order to not to close editor when button is clicked. Answer posted on May 06, 2009 06:12 So the opening of the grid for editing is an onClick event? Answer posted by Alex (support) on May 06, 2009 06:18 In order to edit grid you should double click on the necessary cell. I whote in the previous answer that if the cell editor is opened, click somewhere on the page closes this editor. Answer posted on May 06, 2009 06:24 So closing the grid for editing is an onClick event which gets fired when we click the button to add the row? Answer posted by Alex (support) on May 06, 2009 06:43 The editor is closed when you click on the page (document body). If bubbling is not canceled for button onclick, the editor is closed when you click the button. |