jqgrid没有捡起风格

时间:2011-10-04 12:14:08

标签: c# jquery asp.net asp.net-mvc jqgrid

我的页面上有jqgrid,数据正确加载,但样式看起来很难看。我正在加载这些文件:

<link href="@Url.Content("~/Content/css/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/ui.jqgrid.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/ui.multiselect.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/grid.locale-en.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.jqGrid.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/ui/minified/jquery.ui.core.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/ui/minified/jquery.ui.widget.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/ui/minified/jquery.ui.mouse.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/ui/minified/jquery.ui.tabs.min.js")" type="text/javascript"></script>

我已经检查了Firebug并且它们都正确加载,因此任何脚本都没有任何路径问题。

这是我的实际jqgrid代码:

  $('#brands').jqGrid({
            url: '/GasolineBrands/GasolineBrands/',
            datatype: 'json',
            mtype: 'POST',
            colNames: ['Logo', 'Name', 'No of Stations'],
            colModel: [
                { name: 'Logo', index: 'Logo', width: 150, align: 'left' },
                { name: 'Name', index: 'Name', width: 150, align: 'center' },
                { name: 'No of Stations', index: 'No of Stations', width: 150, align: 'center' },
            ],
            shrinkToFit: false,
            rownumbers: true,
            loadonce: false,
            pager: jQuery('#brandsPager'),
            rowNum: 10,
            rowList: [5, 10, 20, 50],
            sortname: 'Name',
            sortorder: "desc",
            viewrecords: true,
            imgpath: '',
            caption: 'Gasoline Brands',
            width: '100%',
            height: "100%"
        });

这是我的HTML:

<table id="brands">
                </table>
                <div id="brandsPager">
                </div>

有人能发现问题吗?

提前致谢:)

2 个答案:

答案 0 :(得分:2)

我使用的订单:

<link href="/css/smoothness/jquery-ui-1.8.10.custom.css" type="text/css" rel="stylesheet">
<link href="/css/ui.jqgrid.css" type="text/css" rel="stylesheet">
<link href="/css/jquery.multiselect.css" type="text/css" rel="stylesheet">
<link href="/css/jquery.multiselect.filter.css" type="text/css" rel="stylesheet">
<link href="/css/jquery.countdown.css" type="text/css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.ico"> 
<link rel="icon" type="image/ico" href="favicon.ico">
<style>
    .ui-jqgrid tr.jqgrow td {
        white-space: normal !important;
        height:auto;
        vertical-align:text-top;
        padding-top:2px;
    }
</style>

然后是js文件:

    <script src="/js/jquery-1.5.2.min.js" language="javascript"></script>
    <script src="/js/jquery-ui-1.8.10.custom.min.js" language="javascript"></script>
    <script src="/js/jquery-ui-timepicker-addon.js" language="javascript"></script>
    <script src="/js/grid.locale-en.js" language="javascript"></script>
    <script src="/js/jquery.jqGrid.min.js" language="javascript"></script>

然后我的jqGrid添加以下内容:

altRows: true,
altclass: "ui-state-default",

还要在加载时调整网格大小以适合可见区域。如果您也想要该代码,则回复。

我应该提一下我用jquery-ui将我的整个网站主题改为:

<body class="ui-state-default">

适用于我尝试过的每个主题,非常漂亮。希望它有所帮助。

答案 1 :(得分:1)

我发现我必须包含<link href="@Url.Content("~/Content/themes/dark-hive/jquery-ui-1.8.16.custom.css")" rel =“stylesheet”type =“text / css”/&gt;。我做到了,一切顺利。