This is a migrated thread and some comments may be shown as answers.

Default empty grid to Insert mode on form load

4 Answers 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Troy
Top achievements
Rank 1
Troy asked on 23 Dec 2013, 05:14 AM
Hi I have a form with some fields and a radgrid. When the form is opened and if the grids datasource is empty, I want the grid to go into edit mode automatically without the user having to press "Add New Record" first.

I use the grid in batch edit mode as described in this example...
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

After some quick research I've seen advice to use using the following code....
RadGrid1.MasterTableView.IsItemInserted = true
RadGrid1.Rebind()

But unfortunately this just displays the "in-place" edit form rather than simulating "Add New Record" when the grid is in batch editing mode.

Also is it possible to have a custom "Save Changes" and "Cancel Changes" button outside of the grid control elsewhere on the form? This is because I want to allow the users to edit other controls on the form but I want one "Save Changes" button to update everything. My custom Save Changes button will save outher edits on the form and also the grid edits.










4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Dec 2013, 03:52 PM
Hi Troy,

You can use the addNewRecord and saveChanges methods to achieve the requested functionality:
http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html

You can find an sample in the following thread:
http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-fire-the-updateedited-method-from-an-outside-button.aspx

Hope this helps. Please give it a try and let me know if it works for you.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Troy
Top achievements
Rank 1
answered on 28 Dec 2013, 06:14 AM
Thanks, I've got the desired functionality working now.

One issue though...

I couldn't trigger initSaveAllCommand();  in the example using a RadButton. I had to use a normal asp button.

This worked...

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="initSaveAllCommand(); return false;" />

This did not work...

<telerik:RadButton ID="Button1" runat="server" Text="Button" OnClientClick="initSaveAllCommand(); return false;" />

What if I want to use a RadButton instead of a normal ASP Button?

0
Troy
Top achievements
Rank 1
answered on 29 Dec 2013, 04:47 AM
I figured out why RadButton wasn't working on click.

I need to use "OnClientClicked" and the function name without brackets.

So the client side function now fires on clicking BUT I also want to fire a server side function and the server side function is not working.

Any help would be appreciated :)

So my code for this currently is ...

<telerik:RadButton ID="btnUpdate" runat="server" Text="Update" Font-Bold="True" OnClientClicked="initSaveAllCommand" OnClick="btnUpdate_Click"

Width="90px" CssClass="buttonFloatRight" AutoPostBack="true" CausesValidation="false" />

 Protected Sub btnUpdate_Click(sender As Object, e As System.EventArgs) Handles btnUpdate.Click
     ' this is not firing :-(
 End Sub

0
Eyup
Telerik team
answered on 30 Dec 2013, 12:53 PM
Hello Troy,

Please disable the AutoPostBack property of the button and try using the ItemCommand or BatchEditCommand event of the grid:
http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html

Looking forward to your reply.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Troy
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Troy
Top achievements
Rank 1
Share this question
or