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

7 posts, 1 answers
  1. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 28 Dec 2010 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Dec 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 29 Dec 2010 Link to this post

    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?
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Dec 2010 Link to this post

    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.
  6. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 30 Dec 2010 Link to this post

    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.
  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 03 Jan 2011 Link to this post

    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.
  8. jofy
    jofy avatar
    2 posts
    Member since:
    Aug 2011

    Posted 02 Aug 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017