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

How can I tell if the Radgrid is in insertmode?

1 Answer 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Applejax
Top achievements
Rank 1
Applejax asked on 02 Apr 2015, 05:57 PM
I am using the Radgrid as part of a form in asp.net web forms.

People click on "add new record" button to add a new record, fill out the entire row and then,

instead of clicking on "insert" they just click on the "submit" button at the bottom of the page.


I would like to detect if this has occured, and if it has, I would like the row to be inserted.

How can I accomplish this? 

I have already tried what is below, and it does not work.  If an item is currently being inserted, RadGrid1.Items is still 0.

foreach (GridDataItem item in RadGrid1.Items)
            {
                //Set the Name property for the Detail table 
                if(item.IsInEditMode)
                {
                    var x = "here";
                }
            } 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 06 Apr 2015, 02:36 PM
Hello,

I assume that you are using Batch Editing for RadGrid. If this is the case you need to use client-side code in order to save the changes in the grid. You should also ensure that the Button does not perform postback. Check out the following code snippets that illustrate the approach:

Button markup:

<asp:Button Text="Save Changes" runat="server" ID="Button1" OnClientClick="clientClick(this, event); return false;" />

JavaScript handler:

function clientClick(sender, args) {
    var grid = $find("<%= RadGrid1.ClientID %>");
    var masterTableView = grid.get_masterTableView();
    var batchEditingManager = grid.get_batchEditingManager();
 
    batchEditingManager.saveChanges(masterTableView);
}

If you would like additional information on the Batch Editing mode you would find the following article interesting.



Regards,
Viktor Tachev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Applejax
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or