I have this JavaScript code to add a new row using the rowEditingTemplate:
function addRow() {var grid = $find("<%=grdMain.ClientID%>");var row = grid.get_behaviors().get_editingCore().get_behaviors().get_rowAdding().get_row();var ret = grid.get_behaviors().get_editingCore().get_behaviors().get_rowEditingTemplate(); ret.enterEditMode(row); }
When I use this for the button the edit window stays open <input type="button" name="AddRow" value="Add Row " onclick="addRow()" />
When I use this for the button the edit window opens and closes immediately <asp:LinkButton ID="lnkAdd" runat="server" OnClientClick="addRow()">Add</asp:LinkButton>
I would prefer to use the link button because that is what our users are used too.
Is there a way to get the link button working?
Thanks, Pat
Hello Pat,
Thank you for posting in our community.
By default when the asp:LinkButton control is clicked it runs the function specified in the OnClientClick property and then makes a postback. This is the reason why the template closes. By returning false after the execution of the function the issue should be resolved:
<asp:LinkButton ID="lnkAdd" runat="server" OnClientClick="addRow(); return false;">Add</asp:LinkButton>
That worked. Thanks Martin!
I am glad that you find my suggestion helpful.
Thank you for using Infragistics components.