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

Need a button in EditMode

6 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amarinder Singh
Top achievements
Rank 1
Amarinder Singh asked on 28 Jan 2010, 09:28 AM
Hello,

I need a button in editmode of RadGrid as shown in image. On click of this button i need to show a popup which will have two textboxes of usernname and password and a button. on click of button i need to perform database operation. How it can be done?

Thanks
Amarinder

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Jan 2010, 10:41 AM
Hi,

You can add the button to the Edit Form by accessing the parent  item of the Text box control for the Password  field and add it to the control collection. You can then popup a window using a  similar logic in the sample below:
c#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditFormItem editForm = (GridEditFormItem)e.Item; 
            TextBox txtbx = (TextBox)editForm["Password"].Controls[0]; 
            Button btn = new Button(); 
            btn.ID = "btnWindow"
            btn.Text = "Open Window"
            btn.Attributes["onclick"] = String.Format("return ShowForm('{0}');", editForm.ParentItem.OwnerTableView.DataKeyValues[editForm.ParentItem.ItemIndex]["Password"]); 
            txtbx.Parent.Controls.Add(btn); 
             
        }   
    } 

js:
function ShowForm(pwd) 
            {                
                var grid = $find("<%= RadGrid1.ClientID %>");                         
                window.radopen("Page.aspx?Password=" + pwd, "Form"); 
                return false
            } 

Thanks
Princy.
0
Jeremy Yoder
Top achievements
Rank 1
answered on 04 May 2010, 04:16 PM

This is a great example for what I needed as well. Just a couple more questions...

1) This works if EditMode is PopUp, but not InPlace. How can I get it to work for InPlace as well?

2) You referenced the "Password" value from DataKeyValues, but how can I reference any of the field values in the current row in both the server-side and client-side examples you gave?

Thanks.
0
Pavlina
Telerik team
answered on 06 May 2010, 01:06 PM
Hi Jeremy Yoder,

Please go through the help article below, which illustrates how to include additional button when edit mode is InPlace:
Additional action button in auto-generated edit form

I hope this gets upi started properly.

Greetings,
Pavlina
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
Jeremy Yoder
Top achievements
Rank 1
answered on 06 May 2010, 05:16 PM

1) Your link doesn't make sense to me. It tells how to create a Delete GridEditCommandColumn button. That's not what this thread is about, which is an actual button like the first Post's image shows, and how Princy's example makes it happen.

2) Could I get an answer to this question?
0
Pavlina
Telerik team
answered on 12 May 2010, 10:22 AM
Hi Jeremy,

Attached to this message, is a small application, which handles the desired functionality. Check it out and let me know if it works as expected.

I hope this helps.

Kind regards,
Pavlina
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
Jeremy Yoder
Top achievements
Rank 1
answered on 13 May 2010, 09:37 PM

That worked great! Thanks!
Tags
Grid
Asked by
Amarinder Singh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeremy Yoder
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or