带有服务器端分页的 angular js 数据表标识为空

时间:2021-05-19 10:00:41

标签: javascript angularjs datatable

我正在使用带有服务器端分页的 angular js 数据表。我需要检查表是否为空。如果表为空,我需要禁用我的按钮。请检查我的代码

我使用以下函数获取数据。

 $scope.loadRequestApproval = function () {

        $scope.dtOptions = DTOptionsBuilder.newOptions()
            .withOption('ajax', {
                dataType: 'json',
                contentType: "application/json; charset=utf-8",
                url: appConfig.apiUrl + "/finalizedAllList?reqTraceId=" + $scope.requestApprovalId + "&status=PENDING",
                xhrFields: { withCredentials: true },
                type: 'POST',
                data: function (d) {
                    //  console.log(data)
                    return JSON.stringify(d);

                },
                error: function (response) {
                    ajaxErrorHandler.handle(response);
                }
            })

            .withDataProp('data')
            .withOption('processing', true)
            .withOption('serverSide', true)
            .withOption('scrollY', '400px')
            .withOption('scrollX', '100%')
            .withOption('scrollCollapse', true)
            .withOption('searching', true)
            .withOption('drawCallback', function (settings) {

            });
        $scope.dtOptions.withOption('fnRowCallback',
            function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                $compile(nRow, aData, iDisplayIndex, iDisplayIndexFull)($scope);

            });
        $scope.dtColumns = [
            DTColumnBuilder.newColumn('treaceId.traceId').withTitle('Trace ID').notSortable(),
            DTColumnBuilder.newColumn('name').withTitle('Name').notSortable(),
            DTColumnBuilder.newColumn('matchRatio').withTitle('Match Strength %').notSortable(),
            DTColumnBuilder.newColumn('resultId').withTitle('Action').renderWith(function (data, type, full) {
                return '<div class="btn-group-xs">' +
                    '  <button type="button" class="btn btn-flat btn-xs btn-success" ng-click="openDetailViewWindow(\'' + full.resultId + '\');" data-toggle="tooltip" data-placement="right" title="View" tooltip>' +
                    '    <i class="ion ion-eye"></i>' +
                    '  </button>' +
                    '</div>';
            }).withClass('text-center').notSortable()
        ];

    };

这是我的带按钮的 html 页面

      <form class="form-horizontal" name="kycapprovalform">
<button ng-disabled="dtColumns"> Approve</button>
                <div class="row x-scrollable-table">
                    <div class="col-sm-12">
                        <table width="100%" ng-if="dtColumns" id="approval-table" datatable="" dt-options="dtOptions"
                            dt-columns="dtColumns" class="kyc-table table table-bordered table-hover">
                        </table>
                    </div>
                </div>
            </form>

当数据表为空时,我如何禁用我的批准按钮。非常感谢您的帮助

0 个答案:

没有答案
相关问题