【问题标题】:ng-grid not showing grid in ie 8ng-grid 在 ie 8 中未显示网格
【发布时间】:2014-02-19 22:45:39
【问题描述】:

我正在尝试在客户项目中使用 ng-grid 显示一些数据, 一切都很好,除了在 IE8 中(来自 IE11 的模拟模式和 win 7 上的 VM 通过浏览器堆栈),这里的网格没有被渲染(只有用于保存列和行的容器 div 被渲染)和例外我进入控制台的是:

“无法获取未定义或空引用的属性‘宽度’”

“无法获取未定义或空引用的属性'scrollTop'”

在基于 .net 的项目中使用 ng-grid(2.0.7 版)和 angular(1.2.3 版)。 (项目中使用的jQuery版本是1.11。)

由于 IE 中的控制台并没有真正为我提供更多关于跟踪的信息,所以我想如果有人遇到类似问题或者有人知道去哪里寻找线索,我会在 stackoverflow 上向优秀的 ppl 提问。

提前感谢您抽出宝贵时间!

前端代码(添加) 这是前端的部分代码

<div data-ng-controller="benefitsController" >
    <div id="topOrderBox-list" class="topOrderBox">

        <div class="left">
            <div class="boxHeader">
                Sök tjänst
            </div>
            <ul>
                <li>
                    <label class="">
                        <b>Frisökning</b></label>
                    <span class="help" title="Fritextsökning: Här kan du anger olika saker ">[?]</span> </li>
                <li>
                    <input class="freeSearch search" type="text" placeholder="Skriv ett sökord" ng-model="model.filterText" />
                </li>
                <li>
                    <label>
                        <b>Leverantörer</b></label>
                    <span class="help" title="Leverantörer: Här kan du söka efter en viss leverantör">[?]</span> </li>
                <li>
                    <select class="partnersOption" ng-model="model.Partner" ng-options="partner.PartnerName for partner in model.Partners | orderBy:'PartnerName'">
                        <option value="">Välj en leverantör</option>
                    </select>
                </li>
                <li>
                    <label>
                        <b>Välj en typ av förmån</b></label>
                    <span class="help" title="Typ av förmån: Här kan du söka på olika typer av förmåner. ">[?]</span> </li>
                <li>
                    <select class="subCategoryOption" data-ng-model="model.SubCategory" data-ng-options="subCategory.SubCategoryName for subCategory in model.SubCategories | orderBy:'SubCategoryName'">
                        <option value="">Välj en typ av förmån</option>
                    </select>
                </li>
            </ul>
        </div>
        <div class="right">
            <div data-ng-grid="gridOptions" class="gridStyle"></div>
        </div>


        <div data-ng-if="!(selectedRow[0].IsOrderable)" class="benefitDetails overflow" data-ng-show="selectedRow.length > 0">
            <ul>
                <li>
                    <img id="partnerImageId" class="partnerImg" data-ng-src="@Url.Action("Show", "Image")/{{selectedRow[0].PartnerImageId}}" alt="Saknar tjänst bild"/>
                    <img id="benefitImageId" class="benefitImg" data-ng-src="@Url.Action("Show", "Image")/{{selectedRow[0].ImageId}}" alt="Saknar tjänst bild"/>

                    <h2>{{selectedRow[0].PartnerName}} {{selectedRow[0].BenefitName}} {{selectedRow[0].TimeSpanString}}, {{selectedRow[0].City}}</h2>
                </li>

            </ul>
        </div>


    </div>

    <div class="benefitDetails overflow padding-top" ng-show="selectedRow.length > 0">


            <div class="spanDiv">
                <span ng-bind-html="selectedRow[0].CommonDescription"></span>
                <br />
                <br />
                <span class="taxDescription" ng-bind-html="selectedRow[0].TaxDescription"></span>
            </div>

        </div>

    <div class="bottomLinksBox">
        <a data-ng-controller="sendOrderBenefitController" data-ng-click="goToTop()" class="up" href="#">Upp &uarr;</a>

            <a data-ng-if="selectedRow[0].IsOrderable" class="buttonLink rightBox" id="goOnLink" ng-href="@Url.Action("OtherBenefitsOrdering")/{{selectedRow[0].EmployerBenefitId}}" >Gå vidare till beställning</a>

    </div>
    <div class="contractBox">
        <p></p>
    </div>
</div>

这是控制器中的一些代码

adderasApp.controller('benefitsController', ['$scope', 'benefitsService', function ($scope, benefitsService) {

    $scope.model = benefitsService.Benefits.get({ isHealthCare: 'false' }, function () {
        $scope.EmployerBenefits = $scope.model.EmployerBenefits;
    });

    $scope.selectedRow = [];

    $scope.filterOptions = {
        filterText: ''
    };



    $scope.gridOptions = {
        data: 'EmployerBenefits',
        columnDefs: [
            { field: 'PartnerName', displayName: 'Leverantör' },
            { field: 'City', displayName: 'Ort' },
            { field: 'BenefitName', displayName: 'Tjänst' },
            { field: 'SubCategoryName', displayName: 'Kategori' },
            { field: 'PriceString', displayName: 'Pris' },
            { field: 'TimeSpanString', displayName: 'Tid' },
        ],
        multiSelect: false,
        selectedItems: $scope.selectedRow,
        filterOptions: $scope.filterOptions,
        headerClass: 'otherBenefitSearchHeader'
        //headerRowTemplate: '<div ng-style="{\'z-index\': col.zIndex()}" ng-class="{\'col_select\': col.showSortButtonDown(), \'col_select_up\': col.showSortButtonUp() }" ng-repeat="col in visibleColumns()" class="ngHeaderCell col{{$index}}" ng-header-cell></div>'
    };

    $scope.$watch('[ model.Partner, model.SubCategory, model.filterText, model.CommonDescription]', function (newValue, oldValue) {


        var searchText = [];
        var isOrderable;

        if (newValue[0] !== undefined && newValue[0] != null) {
            searchText.push(newValue[0].PartnerName);
        }
        if (newValue[1] !== undefined && newValue[1] != null) {
            searchText.push(newValue[1].SubCategoryName);
        }
        if (newValue[2] !== undefined && newValue[2] != null) {
            searchText.push(newValue[2]);
        }

        if (newValue[3] !== undefined && newValue[3] != null) {
            searchText.push(newValue[3].CommonDescription);
        }

        $scope.filterOptions.filterText = searchText.join(';');



    }, true);

}]);

也尝试关注http://docs.angularjs.org/guide/ie

附:来自工厂/服务的数据正在从同一个域中获取数据,并且数据似乎可以通过,其他不使用 ng-grid 但 restful 服务的页面似乎工作正常。

无论如何,再次感谢您为此付出的时间和精力! 和平

【问题讨论】:

  • 分享代码会很有帮助...
  • 感谢@KristofFeys,现在前端代码和控制器代码已经添加!

标签: c# angularjs internet-explorer-8 ng-grid


【解决方案1】:

我找到了解决方案! :) 基本上它的 IE8 对阅读 js 和 , 非常挑剔。 我在阅读此https://github.com/angular-ui/ng-grid/issues/543 后解决了它 因此,在我的 ng-grid 控制器代码中,我在 gridOptions columnDefs 对象的最后一个参数之后删除了 , 。如:

$scope.gridOptions = {
    data: 'EmployerBenefits',
    columnDefs: [
        { field: 'PartnerName', displayName: 'Leverantör' },
        { field: 'City', displayName: 'Ort' },
        { field: 'BenefitName', displayName: 'Tjänst' },
        { field: 'SubCategoryName', displayName: 'Kategori' },
        { field: 'PriceString', displayName: 'Pris' },
        { field: 'TimeSpanString', displayName: 'Tid' }
    ],
    multiSelect: false,
    selectedItems: $scope.selectedRow,
    filterOptions: $scope.filterOptions,
    headerClass: 'otherBenefitSearchHeader'
    //headerRowTemplate: '<div ng-style="{\'z-index\': col.zIndex()}" ng-class="{\'col_select\': col.showSortButtonDown(), \'col_select_up\': col.showSortButtonUp() }" ng-repeat="col in visibleColumns()" class="ngHeaderCell col{{$index}}" ng-header-cell></div>'
};

无论如何,谢谢你们的投入! ;)

【讨论】:

    【解决方案2】:

    Angular 10 之前的 IE 存在问题。请关注 this guide 以使其正常工作。也就是说,Angular 和 IE8 有一些 very difficult issues to get around

    对于我的应用程序,我必须为 HTML5 支持、Modernizr、完整 jQuery 和 HTML5 控件添加 shims。只是为了支持IE9和回来。而且它充其量是参差不齐的。

    【讨论】:

    • 感谢您的时间和评论,我同意 IE8 似乎让它有点困难。将阅读更多关于垫片等的信息,看看在这种情况下是否有帮助。
    • 感谢您的输入,我们也会将垫片用于其他用途。无论如何,基本的css操作和其他东西都需要现代化工具......叹息。和平:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 2020-03-21
    • 2014-04-29
    • 2014-12-23
    相关资源
    最近更新 更多