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

EditFormSettings popup and grid RowItem new windows popup at the same time

4 Answers 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sharon
Top achievements
Rank 1
sharon asked on 24 May 2016, 09:07 AM

Hi!

   I have a radGrid on the page, which has a [AddNew] button that will trigger a <EditFormSettings> popup window. 

Also, when users click on the Edit button on each row, I also have a code-behind ImgBtn.Attributes.Add("onclick", sb.ToString()) that will popup a window for users to edit data. 

   My problem now is when I click on the Edit button of the gridrow, both windows popup.

It was fine before I add DetailWin.focus to bring the popup to front.   How can I fix this?

Attached is my code, thanks in advaned.

SH.

 

(aspx)
<telerik:RadGrid ID="RadGd1" AutoGenerateColumns="false" PageSize="10" AllowPaging="true" ShowFooter="true" AllowSorting="true"
            ShowStatusBar="true" AutoGenerateDeleteColumn="false" AllowAutomaticInserts="false"
            OnItemCreated ="RadGd1_ItemCreated" OnNeedDataSource="RadGd1_NeedDataSource"
            OnItemDataBound="RadGd1_ItemDataBound"
            Width="90%" Skin="Simple" runat="server">
            <MasterTableView DataKeyNames="FormId" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add New">
                <CommandItemTemplate>
                    <asp:LinkButton ID="lkBtnAdd" runat="server" CommandName="InitInsert" Visible='<%# !RadGd1.MasterTableView.IsItemInserted %>'>
                        <img style="border:0px;vertical-align:bottom; height:16px; margin-top:6px;position:relative; float:left" alt="Add New" src="../images/document_add.png"/>新增
                    </asp:LinkButton>  
                     
                                             
                    <div style="padding-left:20px"></div>
                </CommandItemTemplate>
                                                 
                <Columns>
                    <telerik:GridEditCommandColumn UniqueName="EditCmdCol" ButtonType="ImageButton" ItemStyle-CssClass="" ColumnGroupName="cmdGroup"
                    EditImageUrl="~/images/edit_data_20x19.png" ItemStyle-Width="20" ItemStyle-Height="19">
                        <HeaderStyle />
                    </telerik:GridEditCommandColumn>
 
                    <telerik:GridButtonColumn UniqueName="SaveAsDocCmdCol" ButtonType="ImageButton" ItemStyle-CssClass="" ColumnGroupName="cmdGroup"
                    ImageUrl="~/images/doc_save_as.png" ItemStyle-Width="16" ItemStyle-Height="16">
                    </telerik:GridButtonColumn>
 
                    <telerik:GridButtonColumn UniqueName="SaveAsPdfCmdCol" ButtonType="ImageButton" ItemStyle-CssClass="" ColumnGroupName="cmdGroup"
                    ImageUrl="~/images/pdfDownload_4.png" ItemStyle-Width="16" ItemStyle-Height="16">
                    </telerik:GridButtonColumn>
 
                                                     
                    <telerik:GridBoundColumn HeaderText="CustomerName" DataField="CustomerName" UniqueName="CustomerName" ItemStyle-Width="70px"></telerik:GridBoundColumn>                   
                    <telerik:GridBoundColumn HeaderText="Created Time" DataField="CreateDT" UniqueName="CreateDT" ItemStyle-Width="100px"></telerik:GridBoundColumn>                   
                    <telerik:GridBoundColumn HeaderText="Updated Time" DataField="SentDT" UniqueName="SentDT" ItemStyle-Width="100px"></telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings UserControlName="../UserControl/UCNewCSDetail.ascx" EditFormType="WebUserControl" PopUpSettings-Height="600px" PopUpSettings-Width="800px"
                    PopUpSettings-ScrollBars="Vertical" PopUpSettings-Modal="true" >
                    <EditColumn UniqueName="EditCmdFrm"></EditColumn>
                </EditFormSettings>
                                                
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnPopUpShowing="PopUpShowing" />
            </ClientSettings>
        </telerik:RadGrid>
--------------------------------------------------------
(aspx.cs)
protected void RadGd1_ItemCreated(object sender, GridItemEventArgs e)
        {
             
            if (e.Item is GridDataItem)
            {
                GridDataItem oItem = (GridDataItem)e.Item;
                string strFormId = RadGd1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["FormId"].ToString();
 
                StringBuilder sb = new StringBuilder();
                sb.Append("var DetailWin = window.open");
                sb.Append("('");
                sb.Append("CSDetail.aspx?FormId=" + strFormId);
                sb.Append("',");
                sb.Append("'NewWindow',");
                sb.Append("'scrollbars=yes,status=no,location=no,resizable=yes,Height=650,Width=1000,top=80,left=200'");
                sb.AppendLine("); ");   //return false;
                sb.AppendLine("DetailWin.focus();");
                 
                 
                ImageButton elemImgBtn = (ImageButton)oItem["EditCmdCol"].Controls[0];
                elemImgBtn.Attributes.Add("href", "javscript:void(0);");
                elemImgBtn.Attributes.Add("onclick", sb.ToString());
                                 
            }
    }

 

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 27 May 2016, 06:10 AM
Hello Sharon,

Try replacing the GridEditCommandColumn with a GridButtonColumn to resolve the issue. The GridEditCommandColumn automatically fires an Edit command, which opens the built-in editing pop-up. While the GridButtonColumn will not open the pop-up, unless you manually set its CommandName property to Edit.

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
sharon
Top achievements
Rank 1
answered on 29 May 2016, 07:19 AM

Hi! Eyup

   Thanks for your replying, but, the GridEditCommandColumn actually works fine for me.  The Add New button, which will popup by <EditFormSettings> and <ClientSettings><ClientEvents onPopUpShing="PopUpShowing"></ClientSettings> was the one that popup when I actaully clicked on gridrow column. Any other suggestion? Thank you.

sharon

 

 

0
Kostadin
Telerik team
answered on 01 Jun 2016, 01:34 PM
Hello Sharon,

I would recommend you to examine the following live example which demonstrates how to implement RadGrid editing with RadWindow. If your requirement differs I would appreciate if you can provide more information on your scenario and the issue that you are experience.

Regards,
Kostadin
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
sharon
Top achievements
Rank 1
answered on 13 Jun 2016, 10:19 AM

Hi! Kostadin,

   I actually want the effect as this example: http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/edit-form-types/defaultcs.aspx with usercontrol popup mode, I have provided my code above when I first pasted my question.

The example use GridEditCommandColumn, the usercontrol did not popup as soon as the page loaded.  But in my case, as soon as I hit the page, the Add New user control popup right away.  How to prevent this?

2.  Insid the insert command: protected void RadGridName_InsertCommand(object sender, GridCommandEventArgs e), the example use:  

            System.Web.UI.UserControl oUserControl = (System.Web.UI.UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);

to access the popup usercontrol, but in my case, the object is null?

Any suggestion?

Thanks in advanced!

SH


Tags
Grid
Asked by
sharon
Top achievements
Rank 1
Answers by
Eyup
Telerik team
sharon
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or