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

Add New Record and + sign function differently in Radgrid

5 Answers 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ziying Wu
Top achievements
Rank 1
Ziying Wu asked on 01 Mar 2010, 03:12 PM

Hi,

We have two Radgrids on a web content page. For one grid,  the edit form is an aspx page. When you click edit in the grid, an aspx page is loaded into the edit section of the grid. We created an eventhandler for onbeforeunload event for the aspx page, so when user leaves the aspx page(have the edit section open) and click on a button, linkbutton, leave the content page...etc, a popup will display. This works great except clicking the Add New Record in the other grid displays our pop up and clicking the +sign(left to Add New Record) doesn't, which confuses our users. Refresh button and its sign have the same issue.

Could any body help me?
Thanks & Regards,
Zwu

5 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 04 Mar 2010, 03:18 PM
Hi Ziying Wu,

I am afraid that I can not draw a clear picture of your scenario. Could you provide some code snippets that demonstrate the case you have. The best option would be to open a formal support ticket and send us a small sample runnable project that we could debug locally. This way we would be able to provide you more to the point resolution.

Regards,
Martin
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
Ziying Wu
Top achievements
Rank 1
answered on 04 Mar 2010, 03:39 PM

Hi Martin,

Thanks for the information. 
Telerik created a support ticket for us and I have already created/posted my sample application. So the issue is being taken care of.

 

Thanks,

Ziying

0
Remi
Top achievements
Rank 1
answered on 12 Apr 2010, 10:43 AM
Hi,

I have the same issue with the window.onbeforeunload function in Javascript.
It also triggers the popup when I click on Insert, Update and Cancel.

May I have a snippet or a way to solve this please?
I checked this solution at the bottom of the following link: http://www.telerik.com/community/forums/aspnet/grid/window-onbeforeunload-is-triggered.aspx but it unfortunately doesn't work.
I succeeded in accessing to the right linkbuttons using this kind of procedure on the ItemCreated Event but the modifications of the linkbuttons doesn't seem to work:
void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
        { 
            foreach (Control c1 in e.Item.Controls[0].Controls) 
            { 
                foreach (Control c2 in c1.Controls) 
                { 
                    foreach (Control c3 in c2.Controls) 
                    { 
                        foreach (Control c4 in c3.Controls) 
                        { 
                            if (c4 is LinkButton) 
                            { 
                                LinkButton l = c4 as LinkButton; 
                                l.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(l, string.Empty); 
                            } 
                        } 
                    } 
                } 
            } 
        } 

Thanks for your reply
Remi
0
Ziying Wu
Top achievements
Rank 1
answered on 12 Apr 2010, 05:49 PM
Hi Remi,

Thanks for the code snippet. I didn't try to access the link button but I will sometime.

Our problem is that the plus sign + doesn't call onbeforeunload and AddNewRecord does, which confuses our users.

     1: I give the plus sign a new image and it fires onbeforeunload event. so both fires the event now.
     2:you can use the below snippet to access + and AddNewRecord... what i did is to make one of them invisible so that our users   
        won't be confused---shouldn't they have the same behaviour?

Thanks,
Ziying

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
           
            Button addButton = e.Item.FindControl("AddNewRecordButton") as Button;
           if (addButton != null)
               addButton.Visible = false;
            LinkButton lnkButton = (LinkButton)e.Item.FindControl("InitInsertButton");
            if (lnkButton != null)
                lnkButton.Visible = false;
           
            ........
}


0
Remi
Top achievements
Rank 1
answered on 13 Apr 2010, 03:15 PM
Hi Ziying,

I finally understand your problem, because I'm facing it too!
As I saw on the following link http://www.telerik.com/community/forums/aspnet/grid/window-onbeforeunload-is-triggered.aspx

"Onbeforeunload will be triggered on every A element with href="javascript:SomeFunction();". By default ASP.NET LinkButtons are rendered as <a href="javascript:__doPostBack();" .
"

That's why there is this problem on the "Add a new row" and "Refresh" text. However, the + sign (which is an imagebutton) works perfectly.

I used the following snippet to remove all link buttons.
void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
        { 
            foreach (Control c1 in e.Item.Controls[0].Controls) 
            { 
                foreach (Control c2 in c1.Controls) 
                { 
                    foreach (Control c3 in c2.Controls) 
                    { 
                        foreach (Control c4 in c3.Controls) 
                        { 
                            if (c4 is LinkButton) 
                            { 
                                c4.Visible = false
                            } 
                        } 
                    } 
                } 
            } 
        } 

Any better solution than masking LinkButtons would be appreciated...

-------------------
For my issues with the Insert, Update and Cancel texts, I just had to set the EditColumn-ButtonType to "ImageButton" instead of "LinkButtons".
<EditFormSettings EditFormType="AutoGenerated" EditColumn-ButtonType="ImageButton"
</EditFormSettings> 
I just had to think about it!

Hope my solution fits with somebody problems.

Remi
Tags
Grid
Asked by
Ziying Wu
Top achievements
Rank 1
Answers by
Martin
Telerik team
Ziying Wu
Top achievements
Rank 1
Remi
Top achievements
Rank 1
Share this question
or