1

我正在使用带角度的剑道 UI 网格,我想使用存储在根目录中的 json 文件(model.json)作为 index.html 来绑定网格(我使用的是 Visual Studio 2013 和 web 空项目模板)。我的 javascript 控制器存储在 Scripts/app/ 目录中。这是我的 json 文件:

{
"model":  [
    {
        "RowNumber": "1",
        "AccountNo": "10236",
        "PostingDate": "20.01.2015",
        "AmountDebit": "1800.0",
        "AmountCredit": "1500.0",
        "Balance": "300.0",
        "Description": "Neki Opis"
    },
    {
        "RowNumber": "2",
        "AccountNo": "10648",
        "PostingDate": "26.01.2015",
        "AmountDebit": "3000.0",
        "AmountCredit": "1700.0",
        "Balance": "1300.0",
        "Description": "skafiskafnjak"
    },
    {
        "RowNumber": "3",
        "AccountNo": "10700",
        "PostingDate": "22.01.2015",
        "AmountDebit": "2900.0",
        "AmountCredit": "1800.0",
        "Balance": "1100.0",
        "Description": "knjizenje"
    },
    {
        "RowNumber": "4",
        "AccountNo": "10810",
        "PostingDate": "24.01.2015",
        "AmountDebit": "3800.0",
        "AmountCredit": "1400.0",
        "Balance": "2400.0",
        "Description": "hlabuka"
    },
    {
        "RowNumber": "5",
        "AccountNo": "10101",
        "PostingDate": "29.01.2015",
        "AmountDebit": "3800.0",
        "AmountCredit": "1500.0",
        "Balance": "2300.0",
        "Description": "Neki Opis"
    },
    {
        "RowNumber": "6",
        "AccountNo": "10364",
        "PostingDate": "25.01.2015",
        "AmountDebit": "4300.0",
        "AmountCredit": "1800.0",
        "Balance": "2500.0",
        "Description": "TestNova"
    }
]
}

这是我的控制器:

(function () {
'use strict';

angular.module("app", ["kendo.directives"]).controller("generalledgerController", function ($scope, $http) {

    $scope.gridMaster = {
        dataSource: {
            dataType: "json",
            transport: {
                read: "model.json"
            },
            schema: {
                data: "model"
            }
        },
        selectable: true,
        sortable: true,
        pageable: {
            refresh: true,
            pageSize: true,
            buttonCount: 5
        },
        columns: [
            { field: "RowNumber", title: "R. Br.", width: "50px", template: '<div style="text-align:center;">#= kendo.toString(RowNumber) #</div>' },
            { field: "AccountNo", title: " Br. Knjiženja", width: "77px", template: '<div style="text-align:left;">#= kendo.toString(AccountNo) #</div>' },
            { field: "PostingDate", title: "Datum", width: "70px" },
            { field: "Description", title: "Opis", width: "170px" },
            { field: "AmountCredit", title: "Duguje", width: "80px", template: '<div style="text-align:right;">#= kendo.toString(AmountCredit, "n2") #</div>' },
            { field: "AmountDebit", title: "Potražuje", width: "80px", template: '<div style="text-align:right;">#= kendo.toString(AmountDebit, "n2") #</div>' },
            { field: "Balance", title: "Saldo", width: "80px", template: '<div style="text-align:right;">#= kendo.toString(Balance, "n2") #</div>' }
        ],
        toolbar: ["create"]
    };
});

})();

这是我的html页面:

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html">
    <link rel="stylesheet" type="text/css" media="all" href="content/bootstrap.css">
    <link rel="stylesheet" type="text/css" media="all" href="content/metisMenu.css">
    <link rel="stylesheet" type="text/css" media="all" href="content/bootstrap-theme.css.map">
    <link rel="stylesheet" type="text/css" media="all" href="content/Site.css">
    <link rel="stylesheet" type="text/css" media="all" href="content/kendo/2015.3.1111/kendo.common.min.css">
    <link rel="stylesheet" type="text/css" media="all" href="content/kendo/2015.3.1111/kendo.mobile.all.min.css">
    <link rel="stylesheet" type="text/css" media="all" href="content/kendo/2015.3.1111/kendo.dataviz.min.css">
    <link rel="stylesheet" type="text/css" media="all" href="content/kendo/2015.3.1111/kendo.dataviz.default.min.css">
    <link rel="stylesheet" type="text/css" media="all" href="content/kendo/2015.3.1111/kendo.metro.min.css">
    <link href="content/generalledger.css" rel="stylesheet" />

    <script src="scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="scripts/bootstrap.js"></script>
    <script src="scripts/angular.min.js"></script>
    <script type="text/javascript" src="scripts/kendo/2015.3.1111/kendo.all.min.js"></script>
    <script src="scripts/kendo/2015.3.1111/kendo.web.min.js"></script>
    <script type="text/javascript" src="scripts/app/generalledgercontroller.js"></script>
    <title>App</title>
</head>


<body ng-app="app" ng-controller="generalledgerController">
    <div id="wrapper" class="active">
        <nav class="navbar navbar-inverse navbar-static-top" role="navigation" style="margin-bottom: 0">
            <div class="col-lg-2">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle"
                            data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <h3 class="navbar-brand" style="font-family: 'Lato', calibri;width: 100%;margin: 0;left: 3%;color: grey;font-size: 24px;font-weight: 400">Logo</h3>
                </div>
            </div>
            <div class="collapse navbar-collapse" style="padding-right: 20px">
                <ul class=" nav navbar-nav" style="padding-left:20px"></ul>
            </div>
            <div class="navbar-default sidebar" role="navigation">
                <div class="sidebar-nav navbar-collapse">
                    <ul class="nav" id="side-menu"></ul>
                </div>
            </div>
        </nav>
    </div>
    <div id="page-wrapper">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <div>
                        <div class="divH3Style">
                            <h3 class="h3LabelForm">General Ledger</h3>
                        </div>
                        <div id="tabstrip" class="k-tabstrip-wrapper" kendo-tab-strip="tabStrip">
                            <ul>
                                <li>Overview</li>
                                <li>Update</li>
                            </ul>
                            <div id="tabstrip-1">
                                <div kendo-grid k-options="gridMaster" >
                                </div>
                            </div>
                            <div id="tabstrip-2">
                            <!-- fields for input/update data -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

网格不加载任何数据,我看到的只是标题。我看了这个问题的所有相关链接: Simple Json connection not workingBinding a kendo ui grid to a json file without generate the grid in codehttp://www.telerik.com/forums/simple-json-databinding。 .. 任何帮助,将不胜感激。

4

0 回答 0