0

I'm a newbie at js frameworks and trying out Dojo currently to see if its best for our project. I'm struggling to get things working with Dojo. I attempted using Dojo's dgrid.The code is more or less a straight lift off from the tutorials and I believe I have all the dependecies too (like dgrid/xstyle and put-selector).Still I don't see the grid rendering on the page.Can someone please help me with this.

Here is my js setup(in tomcat)

enter image description here and here is my code(almost straight lift off from the tutorial section)

    <html>
<head>
    <meta charset="utf-8">
    <title>Tutorial: Hello dgrid!</title>
    <!-- this configuration assumes that the dgrid package is located
         on the filesystem as a sibling to the dojo package -->

<!-- load Dojo -->

<script>
    dojoConfig ={
    baseUrl: "js",
    isDebug: true, // enables debug
    async: true, // enables AMD loader
    packages: [
        {
        "name": "dojo",
        "location": "lib/dojo"
        },
        {
        "name": "dgrid",
        "location": "lib/dgrid"
        }   
    ]
    };
</script>
<script src="dojo/dojo.js"></script>
<script>
require(["dojo/parser", "dgrid/Grid", "dojo/domReady!"], function(Grid){
            alert("Hi");
            var data = [
                        { first: "Bob", last: "Barker", age: 89 },
                        { first: "Vanna", last: "White", age: 55 },
                        { first: "Pat", last: "Sajak", age: 65 }
                    ];
            var grid = new Grid(
                    { 
                         columns : {
                                first: "First Name",
                                last: "Last Name",
                                age: "Age"
                            }
                    }, "grid");
            grid.renderArray(data);            
        });
</script>

</head>
<body class="slate">
    <div id="grid" class="slate"></div>
    Hi grid
</body>
</html> 

here is what i see(i don't see the grid at all and there are no js errors too). enter image description here

Chetya
  • 1,267
  • 1
  • 17
  • 31
  • 2
    In the script tag that loads dojo, the src attribute doesn't point to the js/lib folder. Try – psema4 Feb 14 '13 at 20:06
  • Couple of things, with your setup you don't need to add packages or baseUrl. Just set as psema4 wrote. Also: If you want to parse the page for widgets you also need to call parser.parse(); in your function. I know it's not needed for what you have now, but later when you add widgets you will wonder why it doesn't work. – SiCN Mar 11 '13 at 21:46
  • are you sure that there aren't errors in browser's console? – Angelo Jul 18 '13 at 12:29

1 Answers1

0

in Grid there is "dojo/parser" because the first require isn't Grid. Try with

require(["dojo/parser", "dgrid/Grid", "dojo/domReady!"], function(parser,Grid){

or

  require([ "dgrid/Grid", "dojo/parser","dojo/domReady!"], function(Grid){
Angelo
  • 814
  • 8
  • 21