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

Setting multiple rows (but not all) into Edit mode at once

6 Answers 175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerry T.
Top achievements
Rank 1
Jerry T. asked on 28 Dec 2010, 11:08 PM
Ok, I know how to set all rows into Edit mode.

I know how to do the batch update (with UpdateAll).

I know how to set the entire grid into Edit mode initially.

BUT, what I can't figure out, is how to set any number of user-selected rows into Edit mode.  I can only surmise that they must be set into Edit mode via an external button and not via the Edit command for any of the rows currently selected?

Jerry

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Dec 2010, 05:31 AM
Hello Jerry,


You can put the selected rows in Edit mode either by server code or using client code.

Server side approach:
protected void Button1_Click(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.SelectedItems)
    {
        item.Edit = true;
    }
    RadGrid1.MasterTableView.Rebind();      
}


Client side approach:
<script type="text/javascript">
    function editSelected() {
        var grid = $find("<%=  RadGrid1.ClientID%>");
        grid.get_masterTableView().editSelectedItems();
    }
</script>

Hope this helps... :)

-Shinu.
0
Jerry T.
Top achievements
Rank 1
answered on 29 Dec 2010, 02:54 PM
Shinu,

Yeah, I'm sure that code will work but my question is, does that code have to be wired up to an *external* button?  I've tried that and similar ways with the edit button on the row itself but clicking that only puts that row into edit mode. It's like it's losing all of the selected items.  Is there no way for the grid, itself, to be selected items into edit mode without having to use a button external to the grid?
0
Accepted
Shinu
Top achievements
Rank 2
answered on 30 Dec 2010, 01:05 PM
Hello Jerry,


If you want to put all the selected rows in EditMode, then an easy method is setting the CommandName as "EditSelected".

Have a look at the mark-up:
<CommandItemTemplate>
    <asp:Button ID="Button3" runat="server" Text="EditSelected" CommandName="EditSelected" />
</CommandItemTemplate>


Another options is using above code in ItemCommand event to put all the selected rows in editmode.
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "Edit") // check for the corresponding ComamndName set for button
    {
        foreach (GridDataItem item in RadGrid1.SelectedItems)
        {
            item.Edit = true;
        }
        RadGrid1.MasterTableView.Rebind();
    }
}



-Shinu.
0
Jerry T.
Top achievements
Rank 1
answered on 30 Dec 2010, 02:47 PM
Using the CommandItemTemplate is how I've gotten it to work so far but my question is can the grid row editcolumn not trigger the grid to go into edit mode?

I was wanting to avoid using the CommandItemTemplate.  I'd like users to select whatever rows and click one of the edit icons on any of the selected rows to put them all into edit mode.

It appears that is not possible with the RadGrid.
0
Vasil
Telerik team
answered on 03 Jan 2011, 10:59 AM
Hi Jerry T.,

If you do not want use CommandItemTemplate and still want to have button in each row, then you can define a GridemplateColumn with a Button inside its ItemTemplate and use the first approach that Shinu suggested.

Best wishes,
Vasil
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
jofy
Top achievements
Rank 1
answered on 02 Aug 2011, 10:45 AM
Hi ,

I would like to know how  to set all the items of the grid in edit mode without clicking on them. I am using Telerik Mvc Grid - Batch editing on asp.net. I dont want this in Radcontrols.
thanks
Tags
Grid
Asked by
Jerry T.
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jerry T.
Top achievements
Rank 1
Vasil
Telerik team
jofy
Top achievements
Rank 1
Share this question
or