Login Register

Has addRow changed in 1.1.0?

The code below works as is, but if you sub 1.1.0 for the four instances of 1.0.0 it breaks on addRow(). Firebug says "this.store.newItem is not a function".
Has there been a change in addRow for 1.1.0?

Thanks,

George

(Code is modified from http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-devel...)

<head>
        <title>Test dojox.Grid Basic</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
        <style type="text/css">
        @import "http://o.aolcdn.com/dojo/1.0.0/dojox/grid/_grid/tundraGrid.css";
        @import "http://o.aolcdn.com/dojo/1.0.0/dijit/themes/tundra/tundra.css";
        @import "http://o.aolcdn.com/dojo/1.0.0/dojo/resources/dojo.css"
                body {
                        font-size: 0.9em;
                        font-family: Geneva, Arial, Helvetica, sans-serif;
                }
                .heading {
                        font-weight: bold;
                        padding-bottom: 0.25em;
                }
                               
                #grid {
                        border: 1px solid #333;
                        width: 35em;
                        height: 30em;
                }
        </style>
        <script type="text/javascript" src="http://o.aolcdn.com/dojo/1.0.0/dojo/dojo.xd.js"
                djConfig="isDebug:false, parseOnLoad: true">
</script>
        <script type="text/javascript">
            dojo.require("dojo.data.ItemFileReadStore");
                dojo.require("dojox.grid.Grid");
                dojo.require("dojox.grid._data.model");
                dojo.require("dojo.parser");
       
                // a grid view is a group of columns.
                var view1 = {
                        cells: [[
                                {name: 'Namespace', field: "namespace"},
                                {name: 'Class', width: "25em", field: "className"}
                          ],
                          [
                                {name: 'Summary', colSpan:"2", field: "summary"}
                          ]
                        ]
                };
                // a grid layout is an array of views.
                var layout = [ view1 ];
               

    function isGridReady() {
   
      var grid = dijit.byId('grid');
      return (grid.rowCount == grid.model.store._arrayOfTopLevelItems.length && grid.rowCount == grid.model.data.length && grid.rowCount == grid.views.views[0].rowNodes.length);
    }

    function addNewRow() {
   
      if(isGridReady())
        {
          var grid = dijit.byId('grid');
          grid.addRow({namespace:'Hi All'},0);
        }
        else
        {
          setTimeout("addNewRow()",100);
        }
    }
   
    function init() {
   
        var grid = dijit.byId('grid');
        addNewRow([]);
   
    }
   
    dojo.addOnLoad(init);

</script>
</head>
<body class="tundra">
<div class="heading">Our First Grid</div>
        <div dojoType="dojo.data.ItemFileReadStore"
                jsId="jsonStore" url="griddata.txt">

        </div>
        <div dojoType="dojox.grid.data.DojoData" jsId="model"
                rowsPerPage="20" store="jsonStore" query="{ namespace: '*' }">

        </div>
        <div id="grid" dojoType="dojox.Grid" model="model" structure="layout"></div>
</body>

Here's the data file (griddata.txt):

{"items":[{"namespace":"dijit","className":"dijit.ColorPalette","summary":"Grid showing various colors, so the user can pick a certain color","description":null,"examples":null},{"namespace":"dijit","className":"dijit.Declaration","summary":"The Declaration widget allows a user to declare new widget\nclasses directly from a snippet of markup.","description":null,"examples":null},{"namespace":"dijit","className":"dijit.DialogUnderlay","summary":"the thing that grays out the screen behind the dialog\n\nTemplate has two divs; outer div is used for fade-in\/fade-out, and also to hold background iframe.\nInner div has opacity specified in CSS file.","description":null,"examples":null},{"namespace":"dijit","className":"dijit.ProgressBar","summary":"a progress widget\n\nusage:\n<div dojoType=\"ProgressBar\"","description":null,"examples":null}]}

newItem is likely not

newItem is likely not supported for ItemFileReadStore. It may have tolerated newItem in prior releases, but a read store was not intended to permit addition of, changes to, or deletion of items in the read datastore. You may want to try ItemFileWriteStore.

That's it, thanks

ItemFileWriteStore accepts addRow() in 1.1.0. Requires an index value.

Thanks,

George