Opened 11 years ago

Closed 11 years ago

#7349 closed enhancement (fixed)

ContentPane: setContent does not allow Widgets

Reported by: Joscha Feth Owned by: bill
Priority: high Milestone: 1.2
Component: Dijit Version: 1.1.1
Keywords: ContentPane, setContent, Grid Cc:
Blocked By: Blocking:

Description

When using ContentPane? to display a dojox.Grid component in it, the normal way of setting contents does not work:

var cp = new dijit.layout.ContentPane({...},someDiv);
var gridDiv = document.createElement('div');
someDiv.appendChild(gridDiv);
var grid = new dojox.grid.DataGrid({...},gridDiv);
cp.setContent(grid); // this does not work...
cp.startup();

If you set cp._singleChild to contain the widget instead, it works:

var cp = new dijit.layout.ContentPane({...},someDiv);
var gridDiv = document.createElement('div');
someDiv.appendChild(gridDiv);
var grid = new dojox.grid.DataGrid({...},gridDiv);
cp._singleChild = grid; // this works!
cp.startup();

Attachments (1)

test_ContentPane.html (1.4 KB) - added by bill 11 years ago.
corrected testcase (but doesn't do much since the Grid has no data store or other options specified)

Download all attachments as: .zip

Change History (5)

comment:1 Changed 11 years ago by bill

Summary: setContent of ContentPane does not allow WidgetsContentPane: setContent does not allow Widgets
Type: defectenhancement

As your title says, setContent() doesn't take a widget, see the API doc. This isn't a bug per se, it would be an enhancement.

It's because ContentPane is meant to hold free form HTML.

comment:2 Changed 11 years ago by bill

Oh hmm, ignore above comment; the API doc is just out of date; that feature is already there. I'll investigate why your code snippet isn't working.

comment:3 Changed 11 years ago by bill

Milestone: tbd1.2
Owner: set to bill
Status: newassigned

Ugh, ignore my previous comment to "ignore above comment"... even in the newest version of ContentPane, setContent() can only take a string, a dom node, or a node list.

There's also a problem with your code snippet:

someDiv.appendChild(gridDiv);
var grid = new dojox.grid.DataGrid({},gridDiv);
 cp.setContent(grid); // this does not work...

The first line serves no purpose, and actually messes things up, since the setContent() call first deletes all existing content in the ContentPane, including the gridDiv.

Anyway, I will enhance setContent() to be able to take a widget.

comment:4 Changed 11 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [14681]) Fixes #7349: Allow ContentPane?.setContent() to take a widget. !strict

Changed 11 years ago by bill

Attachment: test_ContentPane.html added

corrected testcase (but doesn't do much since the Grid has no data store or other options specified)

Note: See TracTickets for help on using tickets.