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

Image Button inside RadGrid Template Column

3 Answers 1039 Views
Grid
This is a migrated thread and some comments may be shown as answers.
A2H
Top achievements
Rank 1
A2H asked on 22 Sep 2010, 04:07 PM

We had an issue with the radconfirm popup which has to open on the click of delete image button which is present in the Telerik Radgrid template column.

Scenario:

Usually we call a callback function   and get the argument(Yes/NO) which user has selected.

In the call back function we used to get the reference of the button and then do a post back.

We tried the same approach here also, but since the Image button is inside the template column we are unable to get the reference in Javascript.

Question:

How to get the control id of a Image button which is present in a Telerik RadGrid in Javascript ?

Can you please help us on this

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Sep 2010, 06:57 AM
Hello,

You can simply achieve this by using GridButtonColumn.

ASPX:
<telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this record?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" ImageUrl="../Images/Delete.gif" CommandName="Delete" UniqueName="Delete">
</telerik:GridButtonColumn>

Note that, you need RadWindowManager on page.

Thanks,
Princy.
0
A2H
Top achievements
Rank 1
answered on 23 Sep 2010, 10:39 AM
Hi Princy,

Thanks for the Quick reply.

My Requirement is I have to put the button control in grid Template column.

How we can put the Gridbutton column inside the template column.

Please guide me.

Thanks,
A2H
0
Princy
Top achievements
Rank 2
answered on 24 Sep 2010, 07:38 AM
Hello,

If you are using ImageButton inside GridTemplateColumn, then attach an 'OnClientClick' to ImageButton. In the event handler call a RadConfirm for Confiramation dialog. Check out the following code snippet.

ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
</telerik:RadWindowManager>
 
<telerik:RadGrid ID="RadGrid1" . . . . .>
   . . . . . .  . . . . . ..
           <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CommandName="Delete" ImageUrl="~/Images/Delete.gif"
                        OnClientClick="return OnClientClick(this);" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
       . . . . . .  . . . . . ..
</telerik:RadGrid>

Java Script:
<script type="text/javascript">
    var buttonObj;
    var confirmValue = false;
    function OnClientClick(btn) {
        if (!confirmValue) {
            buttonObj = btn;
            radconfirm('Are you sure?', confirmCallBackFn); return false;
        }
    }
    function confirmCallBackFn(arg) {
        if (arg) {
            confirmValue = true;
            buttonObj.click();
        }
    }
</script>

Thanks,
Princy.
Tags
Grid
Asked by
A2H
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
A2H
Top achievements
Rank 1
Share this question
or