How to set the Farpoint Spread control width auto

3k Views Asked by At

I'm having an issue with a Farpoint Spread control which has already set the grid's height by code behind and the width directly in the markup. My question is, is there any way to set the width as auto, because if I open the grid with 1440x900 screen resolution, this grid gets smaller, but If I reduce the screen resolution, the grid is well displayed.

I saw that is possible to determine the screen resolution with Javascript and then I could set a predefined style for each resolution. Can anyone help me with this or have another suggestion that you could provide me?

<tr>
    <td style="padding-left: 10px; padding-top: 15px;" valign="top">
        <farpoint:FpSpread ID="FpSpreadUnitPrice" runat="server" BorderColor="transparent" BorderStyle="None"
            Width="98%">
            <Sheets>
                <farpoint:SheetView DataSourceID="" SheetName="Sheet1">
                    <SelectionBorder BorderStyle="NotSet" BorderStyleBottom="NotSet" BorderStyleLeft="NotSet"
                        BorderStyleRight="NotSet" BorderStyleTop="NotSet" />
                    <RowHeader Width="40" />
                </farpoint:SheetView>                </Sheets>

        </farpoint:FpSpread>
    </td>
</tr>


// Set grid height
int height = 0;
for (int i = 0; i < sh.Rows.Count; i++) {
    int borderSize = 1;
    for (int j=0; j<sh.ColumnCount; j++)
        if (sh.Cells[i, j].Border.BorderSizeTop > borderSize)
            borderSize = sh.Cells[i, j].Border.BorderSizeTop;
    height += sh.Rows.Height + borderSize;
}
this.FpSpreadUnitPrice.Height = height + 10; 
1

There are 1 best solutions below

0
On

The <farpoint:FpSpread> tag can be used just as any <div> tag. So the width can be set automatically with css.

soo.. If you include style="width:100%;height:100%" to the tag, it'll adjust to the size of it's container.

You also will need to remove the width and height attributes from the <farpoint:FpSpread> tag