문제

displaying blank page...please help

require(['dojo/_base/lang', 'dojox/grid/DataGrid', 'dojo/data/ItemFileWriteStore', 'dojo/dom', 'dojox/grid/cells/dijit', 'dojo/domReady!'], function (lang, DataGrid, ItemFileWriteStore, dom)
 {

    var datalist = [{
        col1: 123,
        col2: 'X',
        col3: 'A',
        col4: 29.91,
        col5: 1,
        combo:''
    }, {
        col1:321,
        col2: 'Y',
        col3: 'B',
        col4: 9.33,
        col5: 2,
        combo:''
    }, {
        col1: 456,
        col2: 'Z',
        col3: 'C',
        col4: 19.34,
        col5: 1,
        combo: ''
    }

    ];
      var store = new ItemFileWriteStore({
        data: data
    });
    var layout = [{
        'name': 'SNO',
        'field': 'id',
        'width': '100px',
        'editable':'true'
    }, {
        'name': 'Name',
        'field': 'col2',
        'width': '100px',
        'editable':'true'
    }, {
        'name': 'Batch ',
        'field': 'col3',
        'width': '200px',
        'editable':'true'
    }, {
        'name': 'Percent',
        'field': 'col4',
        'width': '150px',
        'editable':'true'
    }, {
        'name': 'stage',
        'field': 'col5',
        'width': '150px',
            'editable':'true'
    }, {
        'name': 'combo',
        'field': 'combo',
        'width': '200px',
        'type': 'dojox.grid.cells.ComboBox',
        'options':['A','B','C'],
        'editable':true
    }];
    var grid = new DataGrid({
        id: 'grid',
        store: store,
        structure: layout,
        rowSelector: '20px'
    });
    grid.placeAt("gridDiv");
    grid.startup();
});
도움이 되었습니까?

해결책

Don't know if you still need an answer, but when i look at your code i recognize one thing. You define an Array of Data in datalist:

var datalist = [{
    col1: 123,
    col2: 'X',
     ....
    }];

and then fill in the data into the store with data:

 var store = new ItemFileWriteStore({
    data: data
});

It's obvious why there's no data in your Grid because "data" doesnt exist and so no Rows will be displayed in your Grid.

Try it like this:

var datalist= { 
      identifier: 'col1',
      items: [
       { col1: 123, col2: 'X',col3: 'A',col4: 29.91,col5: 1,combo:'' },
       { col1: 321, col2: 'Y',col3: 'B',col4: 9,33,col5: 2,combo:'' },
       { col1: 456, col2: 'Z',col3: 'C',col4: 19,34,col5: 1,combo:'' },
      ]
    };

 var store = new ItemFileWriteStore({
    data: datalist
});

Also your Layout is a bit strange. You don't have a field that's defined "id", but you choose it to make a tableRow?!? I guess you mean the field "col1" instead of "id", right?

Must look like :

var layout = [
            {name:"SNO", field: "col1", width:"30%", editable:true },
            {name:"Name", field: "col2", width:"30%", editable:true },
            .....// and so on
            ];

Then you can start to fill the Grid.

 var grid = new DataGrid({
            id: 'grid',
            store: store,
            structure: layout,
            rowSelector: '20px'
            },"gridDiv");

            grid.startup();
           });

Hope this helps a bit.

Regards, Miriam

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top