开发者

Asp.net MVC-2 with dojo

Is it possible to use dojo (grid in particular) with MVC-2? An开发者_运维问答y example/ideas on how we can use it?


I did not see difference between MVC2 and other types of applications...

You should read about dojo grid

First of all you need to load dojo script (it would be better if you do it on master page). Also you can add some css styles that dojo grid using:

Site.Master:

<html>
   <head>
...
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js" djconfig="parseOnLoad: true"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css" />
<style type="text/css">
    @import "http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/grid/resources/Grid.css";
    @import "http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/grid/resources/claroGrid.css";
    .dojoxGrid table
    {
        margin: 0;
    }
    </style>
...
   </head>
....
</html>

After that you should add some code in view for initialize dojo grid, E.g.:

Index.aspx:

...
<script>
   dojo.require("dojox.grid.DataGrid");
   dojo.require("dojo.data.ItemFileReadStore");
   var layoutCountries = [
       [{
                field: "abbr",
                name: "Abbeviation",
                width: 10
        },
        {
            field: "name",
                name: "Name",
                width: 10
        },
        {
            field: "capital",
                name: "Capital",
                width: 'auto'
        }]];
        var storeData = {
            identifier: 'abbr',
            label: 'name',
            items: [{
                abbr: 'ec',
                name: 'Ecuador',
                capital: 'Quito'
            },
                {
                    abbr: 'eg',
                    name: 'Egypt',
                    capital: 'Cairo'
                },
                {
                    abbr: 'sv',
                    name: 'El Salvador',
                    capital: 'San Salvador'
                },
                {
                    abbr: 'gq',
                    name: 'Equatorial Guinea',
                    capital: 'Malabo'
                },
                {
                    abbr: 'er',
                    name: 'Eritrea',
                    capital: 'Asmara'
                },
                {
                    abbr: 'ee',
                    name: 'Estonia',
                    capital: 'Tallinn'
                },
                {
                    abbr: 'et',
                    name: 'Ethiopia',
                    capital: 'Addis Ababa'
                }]
        }
    </script>
<div style="width: 400px; height: 300px;">
        <div dojotype="dojo.data.ItemFileReadStore" jsid="countryStoreForGrid" data="storeData">
        </div>
        <div id="grid" dojotype="dojox.grid.DataGrid" store="countryStoreForGrid" structure="layoutCountries"
            queryoptions="{deep:true}" query="{}" rowsperpage="40">
        </div>
    </div>
...

And the result of this code is:

Asp.net MVC-2 with dojo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜