Hi,
Row Edit Template can be activated by double click..etc.
Is there anyway to activate it by Javascript?
Thanks!
David
Hey David,
There is a way to open the row edit template via JavaScript. Let me give you the code.
var grid = $find("WebDataGrid1");
var row = grid.get_rows().get_row(0);
var ret = grid.get_behaviors().get_editingCore().get_behaviors().get_rowEditingTemplate();
ret.enterEditMode(row);
This should get you going. Let me know if you have any problems.
regards,
David Young
The above code works, except opening it this way does not fire the RowEditing_TemplateOpened event.
What I am doing is this, I have an "Edit" button in a templated column of my WebDataGrid. I have set the OnClientClick event of that button to do the javascript to enterEditMode on the row.
I need it to fire the TemplateOpened event after that so I can position my Edit Template in the center of the screen.
I have tried putting the code to center it on the screen right after the enterEditMode but the problem is it does not work the first time I click on the Edit button, only the 2nd.
var grid = $find("<%=WebDataGraphics1.WdgGraphics.ClientID %>"); var gridRows = grid.get_rows(); var selectedRows = grid.get_behaviors().get_selection().get_selectedRows(); var row = selectedRows.getItem(0); var rowEditingTemplate = grid.get_behaviors().get_editingCore().get_behaviors().get_rowEditingTemplate(); rowEditingTemplate.set_dropDownEnableAutomaticPositioning(false); rowEditingTemplate.enterEditMode(row) var container = rowEditingTemplate.get_dropDownBehavior().get_targetContainer(); var cntStyle = container.style; cntStyle.position = 'absolute'; cntStyle.marginLeft = "0px"; cntStyle.martinTop = "0px;"; cntStyle.left = (document.documentElement.offsetWidth / 2 + document.body.scrollLeft); cntStyle.top = (document.documentElement.offsetHeight / 2 + document.body.scrollTop);
The code you rpovided is not working for me. I have similar requirement though.