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

[Solved] Grid Edit Mode Popup with User control - sizing

3 Answers 221 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul Mc
Top achievements
Rank 1
Paul Mc asked on 28 Aug 2009, 11:49 AM
 

Hi

We are starting to play with the Rad Grid and investigating the Popup settings with a user control for inserts/updates to the grid.  The grid is being created in code during page init.

        With grd  
            .ID = "grdMyGrid" 
            .AutoGenerateColumns = False 
            .AllowMultiRowEdit = False 
            .AllowPaging = True 
            .AllowSorting = True 
 
            .GridLines = GridLines.None  
            .ShowStatusBar = True 
 
            .MasterTableView.PageSize = 10  
            .MasterTableView.AllowMultiColumnSorting = False 
            .MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top  
            .MasterTableView.DataKeyNames = New String() {"MySerialNo"}  
            .MasterTableView.TableLayout = GridTableLayout.Fixed  
            .MasterTableView.Width = New Unit(100, UnitType.Percentage)  
 
            .MasterTableView.EditFormSettings.UserControlName = "MyUserControl.ascx" 
            .MasterTableView.EditFormSettings.EditFormType = GridEditFormType.WebUserControl  
            .MasterTableView.EditMode = GridEditMode.PopUp  
            .MasterTableView.EditFormSettings.PopUpSettings.Modal = True 
            '.MasterTableView.EditFormSettings.PopUpSettings.Width = New Unit(750, UnitType.Pixel)  
            .MasterTableView.EditFormSettings.CaptionFormatString = "Popup Title" 
 
 
            '... create columns ... 


When the user clicks the edit button to display the edit control, the user control is being displayed as anticipated.  However, because we haven’t declared a width for the popup window, the window borders are being drawn behind the user control at a fixed width of 400px plus 2px of border because the user control is 750px wide.  Obviously I know that we can set the width in code, but I was wondering if there is any way to have the popup auto size its width like it does with the height.

 

 

Thanks in advance.

Paul

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Aug 2009, 10:02 AM
Hello Paul,

You can try resizing the Pop Up width based on its content width in the OnPopUpShowing client event of the grid as shown below:
js:
var popUp;  
function PopUpShowing(sender, eventArgs)   
{   
     
   popUp = eventArgs.get_popUp();      
   popUp.style.width = popUp.children[1].children[0].style.width + 20 ; // to access the content 
    
}  
 

Thanks
Princy.
0
Paul Mc
Top achievements
Rank 1
answered on 02 Sep 2009, 11:25 AM
Hi Princy

Thanks for taking the time to reply to me and sorry for the slow reply.

I dont think 'children' is supported with FireFox, but I think it has set me off in the right direction.  I'm playing with a couple of ideas  at the moment, based on your solution, and will come back to you once I have more info.

Thanks once again.

Paul

0
Paul Mc
Top achievements
Rank 1
answered on 10 Sep 2009, 12:12 PM
For anyone interested, I've managed to get working in all browsers using the follow:

Usercontrol Page:
<div id="PopupSurround">  
    <asp:Table ID="tbl" runat="server">  
 
        <%-- Table content  --%> 
 
    </asp:Table> 
</div> 

Grid page code behind:
With grdOperators     
            .ID = "grdOperations"    
    
            'Other grid properties described in previous post     
    
            .ClientSettings.ClientEvents.OnPopUpShowing = "ResizeGridPopupWindow"    
 


Javascript function:
function ResizeGridPopupWindow(sender, eventArgs) {  
 
    var popUp = eventArgs.get_popUp();  
 
    window.setTimeout(function() {  
        var popupWidth = document.getElementById("PopupSurround").offsetWidth;  
        popUp.style.width = popupWidth + "px";  
    }, 0);  


Hope it helps somebody.

Paul



Tags
Grid
Asked by
Paul Mc
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Paul Mc
Top achievements
Rank 1
Share this question
or