views:

1439

answers:

3

I've read through the posts about dojox.Grid here, including the one about the tabcontainer, but it doesn't seem to solve my problem.

I have a grid that I am adding programmatically which works a treat if the grid is in the "main" markup, but ceases to display if I put the grid in a dialog.

Any ideas as to why? Using dojo 1.3.1.

dijit.byId("myDialog").show();
var gridStore = new dojo.data.ItemFileReadStore({
      data : {
        identifier : "id",
        items      : [
                      {"id" : 1, "label" : "foo"},
                      {"id" : 2, "label" : "bar"},
                      {"id" : 3, "label" : "baz"}
        ]
      }
    });

    /* A simple layout that specifies column headers and
     * mappings to fields in the store */
    var gridLayout = [
            {name : "ID",    field : "id",    width : "50%"},
            {name : "Label", field : "label", width : "50%"}
    ];

    /* Programmatically construct a data grid */
    var grid = new dojox.grid.DataGrid({
                       store     : gridStore,
                       structure : gridLayout
               }, "gridNode");

    /* Tell the grid to lay itself out since
     * it was programmatically constructed */
    grid.startup();

The markup is:

 <div dojoType="dijit.Dialog" id="myDialog" title="Multiple Addresses" style="width:400px;height:300px" >
 <div dojoType="dijit.layout.ContentPane" id="gridNode" style="positon:relative;width:100%;height:100%"></div>

Thanks for any help, Ruprict

+1  A: 

So, the problem I was having seeem to stem from not putting an explicit style on the grid container div (gridNode) Once I did this:

<div dojoType="dijit.layout.ContentPane" id="gridNode" style="width:400px;height:300px"></div>

It started working.

Ruprict
A: 

FYI. I am doing a similar thing (grid in a dialog) and have discovered if I try to modify the store (or at least call setStore on the grid) while the dialog is hidden, errors occur. Just something to watch out for.

Erin Stanfill
A: 

Ruprict,

Your answer did not work for me. Can you please let me know how the grid was displaying when you had the issue?

Vivek
What is happening exactly? Also, what version of dojo? Can you send me a small bit of code that reproduces the issue? --Ruprict
Ruprict
Dojo version is 1.4.1. When I load the Dialog, it shows the grid but with blank headers and blank data. If you can go to my profile and check out the question I have posed for this issue, there is a link to an image which illustrates the problem I am seeing.
Vivek
Ruprict, can you please refer to the below link for the code? http://stackoverflow.com/questions/2342638/dojox-datagrid-contains-data-but-shows-up-as-empty
Vivek