简体   繁体   English

错误类型错误:无法读取未定义的属性“aDataSort”-ANGULAR 8

[英]ERROR TypeError: Cannot read property 'aDataSort' of undefined - ANGULAR 8

Please hope you can help me correct this "aDataSort" error in the datatables.请希望您能帮助我纠正数据表中的“aDataSort”错误。

core.js:6014 ERROR TypeError: Cannot read property 'aDataSort' of undefined
at _fnSortFlatten (jquery.dataTables.js:5928)
at _fnSortingClasses (jquery.dataTables.js:6266)
at loadedInit (jquery.dataTables.js:1208)
at HTMLTableElement.<anonymous> (jquery.dataTables.js:1306)
at Function.each (jquery.js:381)
at jQuery.fn.init.each (jquery.js:203)
at jQuery.fn.init.DataTable [as dataTable] (jquery.dataTables.js:869)
at jQuery.fn.init.$.fn.DataTable (jquery.dataTables.js:15210)
at angular-datatables.directive.js:51
at ZoneDelegate.invokeTask (zone-evergreen.js:391)

It seems to me that the table in the html requires the table to have < thead> < tbody>.在我看来,html 中的表格要求表格具有 <thead> <tbody>。 But I am hiding it with an "if" when the table does not have any records.但是当表没有任何记录时,我用“如果”隐藏它。

<div *ngIf="programaciones?.length==0" class="alert alert-info">
        There is no record in the database!
    </div>

    <div class="table-responsive"  >
    <table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="row-border hover">
        <thead *ngIf="programaciones?.length>0">
            <tr >
                <th>Id</th>
                <th>Consultorio</th>
                <th>Usuario</th>
                <th>Fecha</th>
                <th>Hora</th>
                <th>Num. Turno</th>
                <th>Editar</th>
                <th>Eliminar</th>
            </tr>
        </thead>
        <tbody >
             <tr *ngFor="let programacion of programaciones" >
                <td>{{programacion.pro_codigo}}</td>
                <td>{{programacion.consultorio.con_nombre}}</td>

How can I correct this error, or is there some other way to hide the table when there are no records.我该如何纠正这个错误,或者在没有记录时有其他方法可以隐藏表格。

How about adding display: none/hidden instead of using ngIf如何添加 display: none/hidden 而不是使用 ngIf

Something like this:像这样的东西:

[ngStyle]="programaciones?.length>0 : {'display': 'block'} ? {'display': 'none'}

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

相关问题 未捕获的类型错误:无法读取未定义的属性“aDataSort” - Uncaught TypeError: Cannot read property 'aDataSort' of undefined 无法读取动态数据表的未定义属性&#39;aDataSort&#39; - Cannot read property 'aDataSort' of undefined for dynamic datatable JQuery 数据表:无法读取未定义的属性“aDataSort” - JQuery Datatables : Cannot read property 'aDataSort' of undefined 错误TypeError:无法读取undefined |的属性“0” Angular 4 - ERROR TypeError: Cannot read property '0' of undefined | Angular 4 Angular:ERROR TypeError:无法读取undefined的属性___ - Angular: ERROR TypeError: Cannot read property ___ of undefined jquery-3.5.1.js:4055 错误数据表无法读取未定义的属性“aDataSort” - jquery-3.5.1.js:4055 error DataTables Cannot read property 'aDataSort' of undefined Angular 6 中的“错误类型错误:无法读取未定义的属性‘名称’” - "ERROR TypeError: Cannot read property 'name' of undefined" in Angular 6 Angular 6:ERROR TypeError:无法读取未定义的属性&#39;toLowerCase&#39; - Angular 6: ERROR TypeError: Cannot read property 'toLowerCase' of undefined VIDEOJS:错误:TypeError:无法读取未定义的Angular 5的属性“值” - VIDEOJS: ERROR: TypeError: Cannot read property 'value' of undefined Angular 5 错误类型错误:无法读取 Angular 8 中未定义的属性“值” - ERROR TypeError: Cannot read property 'value' of undefined in Angular 8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM