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

Grid Edit Column

3 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sabyasachi Dechaudhari
Top achievements
Rank 1
Sabyasachi Dechaudhari asked on 01 Apr 2010, 08:13 PM
I have a grid with many cols. I have the grid edit col. and the grid set to edit inline. I need to add a delete button. Can I add it inside the grid edit column (the way it shows images for update and cancel)

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 02 Apr 2010, 01:09 PM
Hello Sabyasachi,

You can use GridButtonColumn and set ShowInEditForm="true" as shown in the code-snippet below:
<telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
    ShowInEditForm="true" UniqueName="DeleteColumn">
    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridButtonColumn>

Kind regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sabyasachi Dechaudhari
Top achievements
Rank 1
answered on 02 Apr 2010, 02:21 PM
Hi,
 What I need is the delete button comming in the same column as the edit button/image (due to space constaraints) rather than have a new column.{Just the way and update and cancel image appear in the same column}
0
Daniel
Telerik team
answered on 02 Apr 2010, 03:26 PM
Hello Sabyasachi,

There are several ways to achieve this. One of the easiest approaches would be to use a template column:
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:ImageButton ID="ImageButton1" CommandName="Edit" runat="server" ImageUrl="editButton.gif"
            AlternateText="Edit" />
    </ItemTemplate>
    <EditItemTemplate>
        <asp:ImageButton ID="ImageButton1" CommandName="Update" runat="server" ImageUrl="updateButton.gif"
            AlternateText="Update" />
        <asp:ImageButton ID="ImageButton2" CommandName="Delete" runat="server" ImageUrl="deleteButton.gif"
            AlternateText="Delete" />
        <asp:ImageButton ID="ImageButton3" CommandName="Cancel" runat="server" ImageUrl="cancelButton.gif"
            AlternateText="Cancel" />
    </EditItemTemplate>
</telerik:GridTemplateColumn>

You can also insert the delete button in code-behind:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item.IsInEditMode)
    {
        ImageButton deleteButton = new ImageButton();
        deleteButton.ID = "deleteButton1";
        deleteButton.CommandName = "Delete";
        deleteButton.AlternateText = "Delete";
        deleteButton.ImageUrl = "myImage.gif";
        (e.Item as GridEditableItem)["AutogeneratedEditColumn"].Controls.Add(deleteButton);
    }
}

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Sabyasachi Dechaudhari
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Sabyasachi Dechaudhari
Top achievements
Rank 1
Share this question
or