Asp.net MVC-2道场 [英] Asp.net MVC-2 with dojo

查看:113
本文介绍了Asp.net MVC-2道场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能与MVC-2使用Dojo(特别是网格)?例如任何/对我们如何使用它呢?想法

Is it possible to use dojo (grid in particular) with MVC-2? Any example/ideas on how we can use it?

推荐答案

我没看到MVC2和其他类型的应用程序之间的区别...

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

您应该阅读有关 Dojo网格

You should read about dojo grid

你需要加载道场脚本(它会更好,如果你这样做母版页上)第一。
您还可以添加使用Dojo网格一些CSS样式:

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:

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>

之后,你应该添加一些code是鉴于初始化Dojo网格,例如:

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

Index.aspx的:

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>
...

这code的结果是:

And the result of this code is:

这篇关于Asp.net MVC-2道场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆