简体   繁体   English

ui-grid未显示数据angularjs

[英]ui-grid not showing data angularjs

Can someone please help me. 有人可以帮帮我吗。 I want to implement data display using ui-grid. 我想使用ui-grid实现数据显示。 But the grid is not displaying data just showing blank yet when i use table with <tr ng-repeat="transaction in savingaccountdetails.transactions> data is displayed. 但是,当我<tr ng-repeat="transaction in savingaccountdetails.transactions>数据<tr ng-repeat="transaction in savingaccountdetails.transactions>表与<tr ng-repeat="transaction in savingaccountdetails.transactions>一起使用时,表仍未显示数据。

I want to use ui-grid because of the ability to have fixed header while scrolling for large data but its so hard to make table header fixed, most times columns don't align. 我想使用ui-grid,因为在滚动大数据时能够具有固定的标头,但是很难使表格标头固定,多数情况下列不对齐。 i tried most cases but not working as expected. 我尝试了大多数情况,但没有按预期工作。

My codes are as below:- 我的代码如下:

var columnsUiGrid = [
                { displayName: 'Value Date', field: 'accountdetails.transactions.date'},
                { displayName: 'Seq', field: 'accountdetails.transactions.id'},
                { displayName: 'Number', field: 'accountdetails.transactions.transactionCode'},
                { displayName: 'Type', field: 'accountdetails.transactions.transactionCode'},
                { displayName: 'Debit', field: 'accountdetails.transactions.amount'},
                { displayName: 'Credit', field: 'accountdetails.transactions.amount'},
                { displayName: 'Balance', field: 'accountdetails.transactions.runningBalance'},
                { displayName: 'Tlr#', field: 'accountdetails.transactions.teller'},
                { displayName: 'Reference', field: 'accountdetails.transactions.referenceCode'},
                { displayName: 'Description', field: 'accountdetails.transactions.description'}
            ];
            scope.gridOptions = {
                columnDefs: columnsUiGrid,
                enableSorting: false,
                enableColumnMenus: false,
                enableRowSelection: true,
                enableRowHeaderSelection : false,
                multiSelect: false,
                data: 'accountdetails'
            };

resourceFactory.savingsResource.get({accountId: routeParams.id, associations: 'all'}, function (data) {
                scope.accountdetails = data;
            });

From the above i get the following errors from web browser console:- When i use with the quotes ie 'accountdetails' i get the error below:- 从上面我从网络浏览器控制台中收到以下错误:-当我使用引号即“ accountdetails”时,出现以下错误:-

angular.js:9400 TypeError: d.$applyAsync is not a function
    at h (http://localhost:9000/bower_components/angular-ui-grid/ui-grid.min.js:7:2757)
    at post (http://localhost:9000/bower_components/angular-ui-grid/ui-grid.min.js:7:4152)
    at http://localhost:9000/bower_components/angular/angular.js:6602:44
    at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:6224:13)
    at http://localhost:9000/bower_components/angular/angular.js:6414:13
    at http://localhost:9000/bower_components/angular/angular.js:7559:11
    at wrappedCallback (http://localhost:9000/bower_components/angular/angular.js:10930:81)
    at http://localhost:9000/bower_components/angular/angular.js:11016:26
    at Scope.$eval (http://localhost:9000/bower_components/angular/angular.js:11936:28)
    at Scope.$digest (http://localhost:9000/bower_components/angular/angular.js:11762:31) <div ui-i18n="en" class="influxGrid ui-grid ng-isolate-scope grid1505208757076" id="transactionGrid" ui-grid-selection="" ui-grid="gridOptions" style="height: 340px;">
(anonymous) @ angular.js:9400
(anonymous) @ angular.js:6836
nodeLinkFn @ angular.js:6227
(anonymous) @ angular.js:6414
(anonymous) @ angular.js:7559
wrappedCallback @ angular.js:10930
(anonymous) @ angular.js:11016
$eval @ angular.js:11936
$digest @ angular.js:11762
$apply @ angular.js:12042
(anonymous) @ angular.js:13575
completeOutstandingRequest @ angular.js:4109
(anonymous) @ angular.js:4416
angular.js:9400 TypeError: b.forEach is not a function
    at p.modifyRows (ui-grid.min.js:7)
    at ui-grid.min.js:7
    at wrappedCallback (angular.js:10930)
    at angular.js:11016
    at Scope.$eval (angular.js:11936)
    at Scope.$digest (angular.js:11762)
    at Scope.$apply (angular.js:12042)
    at angular.js:13575
    at completeOutstandingRequest (angular.js:4109)
    at angular.js:4416

I don't really know why you are using the scope as "scope" and not like "$scope". 我真的不知道为什么将示波器用作“ scope”而不是“ $ scope”。 I couldn't say where your problem is but maybe if you try your code this way: 我不能说您的问题出在哪里,但也许如果您这样尝试代码:

var columnsUiGrid = [
            { displayName: 'Value Date', field: 'accountdetails.transactions.date'},
            { displayName: 'Seq', field: 'accountdetails.transactions.id'},
            { displayName: 'Number', field: 'accountdetails.transactions.transactionCode'},
            { displayName: 'Type', field: 'accountdetails.transactions.transactionCode'},
            { displayName: 'Debit', field: 'accountdetails.transactions.amount'},
            { displayName: 'Credit', field: 'accountdetails.transactions.amount'},
            { displayName: 'Balance', field: 'accountdetails.transactions.runningBalance'},
            { displayName: 'Tlr#', field: 'accountdetails.transactions.teller'},
            { displayName: 'Reference', field: 'accountdetails.transactions.referenceCode'},
            { displayName: 'Description', field: 'accountdetails.transactions.description'}
        ];
        $scope.gridOptions = {
            columnDefs: columnsUiGrid,
            enableSorting: false,
            enableColumnMenus: false,
            enableRowSelection: true,
            enableRowHeaderSelection : false,
            multiSelect: false,
            data: $scope.accountdetails
        };
resourceFactory.savingsResource.get({accountId: routeParams.id, associations: 'all'}, function (data) {
                $scope.accountdetails = data;
            });

Please let us know more details about your problem 请让我们知道有关您的问题的更多详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM