A grid (W:100% - H 100%) within a dialog is bigger than the dialog's content

I created a simple dialog containing a grid with just Width and Height at 100%.

The grid's height is bigger than the content height.

Brice.

Attachment: GridInDialog_c982f5da.7z

4 Replies 1 reply marked as answer

IS Indrajith Srinivasan Syncfusion Team July 9, 2020 12:48 PM UTC

Hi Brice,

Greetings from Syncfusion support,

We have checked the shared sample. In the sample a static Height of “500px“ is set for the SfDialog, hence the dialog content is shown bigger till the height specified. If the Height is not specified the dialog content will be adjusted based on the content Height.

Please let us know if you need any further assistance,

Regards,
 
Indrajith 



BF Brice FROMENTIN July 9, 2020 01:29 PM UTC

The calc operation is wrong, it should be (100% - height of header - height of pager - ...).

Attachment: Height_Bug_11f91a07.7z


BF Brice FROMENTIN July 9, 2020 01:33 PM UTC

Just try resizing the dialog without heigth and the bug come back. 


IS Indrajith Srinivasan Syncfusion Team July 14, 2020 08:13 AM UTC

Hi Brice,   
 
Query: “The grid's height is bigger than the content height. && Just try resizing the dialog without heigth and the bug come back. ”  
  
From your query we understand that you are facing issue with Grid Height not being adjusted into the Dialog content. By default Grid will be adjusted to browser element width and height. So if you want to adjust the Grid height and width to inside the dialog (container). We need to specify the Height and Width of Grid as 100% and static height and width to immediate parent of Grid’s div element. So we suggest you to define the static height to immediate parent element to Grid (refer the below code).    
  
And also we suggest you to render the Grid only after the Dialog is displayed. We have modified the your sample to show the Dialog using @bind-Visible property instead of Show method.   
  
Refer the below code example   
  
<SfDialog @ref="@dialog"  
          IsModal=true ShowCloseIcon="true" AllowDragging=true EnableResize=true  
          Width="800px"  
          @bind-Visible="@visible">  
    <DialogTemplates>  
        <Content>  
            @{  
                if (visible) // render Grid after displaying the dialog  
                {  
                    <div style="height:250px"> //static height to immediate parent  
                        <SfGrid ID="SGrid" TValue="ExpandoObject" EnablePersistence="true"  
                                AllowSorting="true" AllowPaging="true" AllowFiltering="true" AllowResizing=true EnableAltRow="true"  
                                Width="100%" Height="100%">  
                            <GridPageSettings PageSize="50" PageSizes="new int[] { 25, 50, 100, 250, 500 }" />  
                            <GridColumns>  
                                <GridColumn HeaderText="Test"></GridColumn>  
                            </GridColumns>  
                        </SfGrid>  
                    </div>  
                }  
            }  
        </Content>  
    </DialogTemplates>  
</SfDialog>  
   
@code  
{  
    SfDialog dialog;  
    public bool visible = false 
    void OnClick()  
    {  
        visible = true;  
    }  
}  
  
  
For your convenience we have modified the sample which can be downloaded from below   
  
  
Kindly get back to us if you have further queries.      
  
Regards,  
Indrajith 


Marked as answer
Loader.
Up arrow icon