【问题标题】:ui grid expandable not showing dataui网格可扩展不显示数据
【发布时间】:2017-11-26 06:18:56
【问题描述】:

我正在尝试在可扩展选项中绑定 ui-grid。我能够获取数据,但似乎具有约束力,我错过了一些东西。有人可以建议吗

这是我的代码

--控制器--

                            // JavaScript source code
            $scope.gridOptions = {
                expandableRowTemplate: 'expandableRowTemplate.html',
                expandableRowHeight: 150,
                //subGridVariable will be available in subGrid scope
                expandableRowScope: {
                    subGridVariable: 'subGridScopeVariable'
                }
            }

            $scope.gridOptions.columnDefs = [
            { name: 'check_number', field: 'check_number', displayName: 'check_number' }

            ];

            var callData = function () {
                alert('call data');
                return $http({
                    method: "post",
                    url: "/Common/Metasystem/AP/Reports/ReportData.aspx/GetcheckReportData",
                    dataType: 'json',
                    data: { beforedt: '01/01/2018', afterdt: '01/01/1900', checknumberlist: '' },
                    headers: { "Content-Type": "application/json" }
                }
                )
            };

            $scope.fetchResult =
            function () {
                // alert('call');
                $scope.gridOptions.data = 'aa';
                callData()
                .success(function (resultvalue) {
                    // $scope.resultdata = "[" + JSON.stringify(resultvalue.d) + "]";//issue
                    $scope.resultdata = JSON.parse(resultvalue.d);
                    for (i = 0; i < $scope.resultdata.length; i++) {

                        $scope.resultdata[i].subGridOptions = {
                            columnDefs: [{ name: "check_number", field: "check_number", displayName: 'check_number' }, { name: "voucher_number", field: "voucher_number", displayName: 'voucher_number' }],
                            data: $scope.resultdata[i].friends
                        }
                    }
                    $scope.gridOptions.data = $scope.resultdata;
                })
                .error(function (data) {
                    console.error('Repos error', data);
                })
            };
            $scope.fetchResult();

--- 来自 webmethod 的 json 数据

            [{
                "Check_number": "116511",
                "Check_date": "2012-11-21T00:00:00",
                "Detail": [{
                    "Check_number": "116511",
                    "Voucher_number": "10000115",
                    "Invoice_number": "10000115",
                    "Invoice_date": "2017-03-23T16:03:38.303",
                    "Invoice_amount": 125.0,
                    "Vendor_number": "01234"    
                }, {
                    "Check_number": "116511",
                    "Voucher_number": "10000115",
                    "Invoice_number": "10000115",
                    "Invoice_date": "2017-03-23T16:03:38.303",
                    "Invoice_amount": 125.0,
                    "Vendor_number": "01234"        
                }]
            }]

--------- aspx 页面

            <div ng-controller="MainCtrl" ng-app="app">
            <div class="control-group">
            <input type="button" class="btn btn-small" ng-click="expandAllRows()" value="Expand All"/>
            <input type="button" class="btn btn-small" ng-click="collapseAllRows()" value="Collapse All"/>
            </div>
            <div ui-grid="gridOptions" ui-grid-pinning ui-grid-expandable class="grid"></div>
            </div>

【问题讨论】:

    标签: jquery asp.net json angular-ui-grid webmethod


    【解决方案1】:

    找到了。分配错误。

    $scope.gridOptions.data = 'resultdata';

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      • 2012-04-19
      • 2018-08-04
      • 1970-01-01
      相关资源
      最近更新 更多