How do I programmatically set the height on an SfGrid?

I need to compute the height, so I did the following:

I added CssClass="e-grid-height" to the SfGrid tag

I created the following style:

    .e-grid-height {
        height: @PalettenGridHeight;
    }

where PalettenGridHeight is a function returning a string value like e.g. "150px"

But PalettenGridHeight doesn't even get called when I debug my application.


1 Reply

RS Renjith Singh Rajendran Syncfusion Team March 7, 2022 12:54 PM UTC

Hi Dietfrid, 
 
Greetings from Syncfusion support. 
 
We have inbuilt Height property for Grid. So, based on this scenario, we suggest you to use property binding for the Grid’s Height property. Please refer and use as like the code below, 
 
 
<SfButton OnClick="ChangeHeight">ChangeHeight</SfButton> 
 
<SfGrid DataSource="@Orders" Height="@PalettenGridHeight"> 
    ... 
</SfGrid> 
 
    public string PalettenGridHeight = "400px"; 
    public void ChangeHeight() 
    { 
        PalettenGridHeight = "250px"; 
    } 


 
Please get back to us if you need further assistance. 
 
Regards, 
Renjith R 


Loader.
Up arrow icon