Opened 14 years ago

Closed 13 years ago

#5651 closed defect (fixed)

Grid.render() for grid in <div> with other child-Elements resizes wrong.

Reported by: guest Owned by: Nathan Toone
Priority: high Milestone: 1.2
Component: DojoX Grid Version: 1.0
Keywords: Grid render() render resize prerender parent Cc:
Blocked By: Blocking:

Description (last modified by dylan)

I have the following code in my html:

<div tal:define="idTable string:llselectiontbl_$lltype" style="height:70%">
    <input type="hidden" id="JsonTableName" tal:attributes="value idTable" />
    <input type="hidden" id="selected_product" name="selected_product" value=""/>
    <input type="hidden" id="selected_product_short" name="selected_product" value=""/>
    <hr style="color:green"/>
    <div id="llselectiontbl_" style="width: 98%"/>
    <hr style="color:green"/>
    <script type="dojo/method">
        this.addOnLoad(function(){ debugger; displaySelectionTable('', '$forceOpenSingleLL')});;
        this.addOnUnload(function(){ debugger; removeSelectionTable()});;

The Grid is then created via JavaScript?:

var tbl = new dojox.Grid({ 
        id: "llselectiontbl_", 
        autoHeight: false, autoWidth: false, defaultHeight: '20em',
        structure: selectionTblLayout, 
        model: llSel.selectionTblModel 
    }, "llselectiontbl_"); 

When the window-size changes, Grid.render() is called. In Grid.render() / prerender() / resize() there is a part that calculates the new height by the height of the parent container. Because the parent in this case also contains two <hr>-elements, the height of the parent is generally 15px higher than the Grid. Because of the render() now, the Grid gets adjusted to Gridsize+15px which also stretches the parent <div>. This happens every time render() is called, so the Grid grows vertically every time - which after a while makes it really long - and is definetly unwanted.

Change History (8)

comment:1 Changed 14 years ago by dylan

Owner: changed from anonymous to sorvell
Priority: highnormal

comment:2 Changed 14 years ago by dylan

Component: GeneralDojoX Grid
Description: modified (diff)

comment:3 Changed 13 years ago by Bryan Forbes

Owner: changed from sorvell to Bryan Forbes

comment:4 Changed 13 years ago by Nathan Toone

Resolution: invalid
Status: newclosed

Unless you are using a grid within a layout widget, you should either be using autoHeight=true or setting the height. In your case, you should be able to just style your div to be "width: 98%; height: 20em;" (instead of just specifying the width there).

comment:5 Changed 13 years ago by Nathan Toone

Resolution: invalid
Status: closedreopened

So apparently, setting the height of the div doesn't "stick" - reopening.

comment:6 Changed 13 years ago by Nathan Toone

Owner: changed from Bryan Forbes to Nathan Toone
Status: reopenednew

comment:7 Changed 13 years ago by Nathan Toone

Status: newassigned

comment:8 Changed 13 years ago by Nathan Toone

Resolution: fixed
Status: assignedclosed

(In [14844]) Fixes #5651 - allow for setting an explicit height - either via a height: attribute or using the height: css declaration on the source node. If that height is set, then it is used - rather than fitting to the parent. !strict

Note: See TracTickets for help on using tickets.