【问题标题】:How to use the date-formatter of bootstrap-table in angular2?如何在angular2中使用bootstrap-table的日期格式化程序?
【发布时间】:2017-08-17 20:38:31
【问题描述】:

您好,我正在使用带有 Angular4 的引导表库。但是使用 date-formatter 并没有给我带来任何价值。

代码html:

<table id="table" data-show-refresh="true" data-show-toggle="true" data-show-columns="true">
                                    <thead>
                                        <tr>
                                            <th data-field="state" data-checkbox="true"></th>
                                            <th data-field="userId" data-sortable="true">Usuario</th>
                                            <th data-field="userName" data-sortable="true">Nombre</th>
                                            <th data-field="lastName" data-sortable="true">Apellido</th>
                                            <th data-field="email" data-sortable="true">Correo</th>
                                            <th data-field="mobilePhone">Teléfono</th>
                                            <th data-field="cargo">Cargo</th>
                                            <th data-field="evento" data-formatter="acciones">Eventos</th>
                                        </tr>
                                    </thead>
                                </table>

代码打字稿:

  tableRow(data){
    $(function () {
        $('#table').bootstrapTable({
            data: data,
            pagination: true,
            pageNumber: 1,
            pageSize: 10,
            search: true,
            minimumCountColumns: 2,
            iconsPrefix : 'icon',
            icons: {
              refresh: 'ion-ios-loop-strong',
              toggle: 'ion-ios-list-outline',
              columns: 'ion-ios-more'
            }
        });
    });
    function acciones(){
      return "<a href='/user:id' />Edit</a>";
    }
  }

【问题讨论】:

    标签: javascript angular bootstrap-table


    【解决方案1】:

    函数acciones只定义在typescript函数tableRow中。

    bootstrap-table 的data-formatter 似乎使用了全局函数(即在window 中定义)。

    这应该可行:

    window.acciones = function () {
      return '<a href="/user:id">Edit</a>';
    };
    

    注意:我不认为bootstrap-table 与Angular 兼容。我不建议在这种环境中使用jQuery 插件。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-09
    • 1970-01-01
    • 2019-11-25
    • 2018-10-03
    • 2017-04-29
    相关资源
    最近更新 更多