【问题标题】:PrimeNG dataTable rowspan examplePrimeNG 数据表行跨度示例
【发布时间】:2017-02-01 21:13:10
【问题描述】:

我正在使用 PrimeNG 数据表。我想让一些行跨越表格内容中的几列。在标题 (http://www.primefaces.org/primeng/#/datatablegroup) 中有一个很好的示例,但我不确定如何在表格内容中执行此操作。行数将是动态的(有些可能有 Weather 和 Rain,其他可能有 Rain、Water Level 和 Streamflow)。这个可以吗?

visual for rowspan > 1

【问题讨论】:

    标签: datatable primeng


    【解决方案1】:

    我遇到了同样的问题。我真的想不出一个原生解决方案,所以我这样做了。

    <p-dataTable [value]="checkout.items" [footerRows]="footerRows">
            <p-column field="main_title" header="Items" styleClass="item-width">
    
                <template let-col let-mainVO="rowData">
    
                    <tr><h4>{{mainVO[col.field].main_title}}</h4></tr>
                    <tr *ngFor="let c of mainVO[col.field].childVO">
                        <td>{{c.title}}</td>
                        <td>{{c.price}}</td>
                    </tr>
                    <tr><h4>Discounts:</h4></tr>
                    <tr *ngFor="let d of mainVO[col.field].discounts">
                        <td>{{d.title}}</td>
                        <td>{{d.price}}</td>
                    </tr>
                    </template>
            </p-column>
            <p-column field="quantity" header="Quantity"></p-column>
            <p-column field="price" header="Price"></p-column>
            <p-column field="action" header="Action">
                <template>
                    <a href="javascript:void(0)">Delete</a>
                </template>
            </p-column>
    
        </p-dataTable>
    

    这是我的 json:

     this.checkout =
            {
                Message: "CheckoutList",
    
                items: [
                    {
                        mainVO:{
    
                            main_title: "Value Pack Combo",
    
                            childVO: [
                                {
                                    title: "Financial e-Tutorial",
                                    price: "$55"
                                },
    
                                {
                                    title: "e-Tutorial",
                                    price: "$75"
                                },
                                {
                                    title: "Ratios e-Tutorial",
                                    price: "$85"
                                },
    
                                {
                                    title: "economics e-Tutorial",
                                    price: "$95"
                                }
                            ],
                            discounts: [
                                {
                                    title: "Discount price 1",
                                    price: "$120"
                                },
                            ]
                        },
    
                        quantity: "1",
    
                        price: "300",
                        currency: "CAD"
    
                    },
                    {
                        mainVO:{
    
                            main_title: "Securities Pack Combo",
    
                            childVO: [
                            {
                                title: "atios e-Tutorial",
                                price: "$55"
                            },
    
                            {
                                title: "omicsrial",
                                price: "$75"
                            },
                            {
                                title: "e-Tutorial",
                                price: "$85"
                            },
    
                            {
                                title: "Micro Tutorial",
                                price: "$95"
                            }
                            ],
                            discounts: [
                            {
                                title: "Discount price 1",
                                price: "$120"
                            },
                            ]
                        },
    
                        quantity: "1",
    
                        price: "300",
                        currency:"CAD"
                    },
                ],
    
            }
    

    【讨论】:

    • 太棒了!!我真的需要更多地使用模板选项!一个问题:模板化的表格部分周围有一个边框(因此表格周围的单元格内有空间)。我试过使用 css border-style: none 和 padding: 0px ,这似乎没有做任何事情。你有这个问题吗?再次感谢您的洞察力!
    • 嗯,你能详细说明一下吗?我不明白你的问题。可以附上图片吗?
    • 我希望我已经截屏了。它看起来像一张桌子中的一张桌子(包括外边框)。我最终做的是: p-column> 但你给我的东西让我开始走上正轨,所以谢谢!!!
    • 酷。如果您满意,您可以接受答案。 :p
    猜你喜欢
    • 2018-12-19
    • 2016-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-30
    • 2011-01-02
    • 2012-10-19
    • 1970-01-01
    相关资源
    最近更新 更多