0

For example I have a following smart table which I've created by using smart table angularjs module and following SO answer:

           <table st-table="positions" class="table">
                <thead>
                    <tr>
                        <th class="text-center">Menu</th>
                    </tr>
                </thead>
                <tbody ng-repeat="position in positions">
                    <tr>
                      <th class="warning">{{position.title}}</th>
                    </tr>
                    <tr ng-repeat="item in position.items">
                      <td>{{item.title}}</td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td class="text-center" 
                            st-pagination="" 
                            st-items-by-page="5" 
                            st-displayed-pages="7">
                        </td>
                    </tr>
                </tfoot>
            </table>

JSON data for this list are following:

{
    "positions" : [{
            "title" : "position 1",
            "id" : 1,
            "items" : [{
                    "id" : 1,
                    "title" : "position 1 - item 1"
                    }, {
                    "id" : 2,
                    "title" : "position 1 - item 2"
                }
            ]
        }, {
            "title" : "position 2",
            "id" : 2,
            "items" : [{
                    "id" : 3,
                    "title" : "position 2 - item 3"
                }
            ]
        }
    ]
}

Table has been build as I wish but pagination doesn't work and I suspect that it's because I've used st-table="positions"

st-table attribute to tell smart-table which collection holds your displayed data,

positions array doesn't represent all rows of the table.

Thank you.

Community
  • 1
  • 1
Anatoly
  • 5,056
  • 9
  • 62
  • 136
  • If that array doesn't represent all data then what does? Missing some critical information here – charlietfl Aug 11 '15 at 14:26
  • @charlietfl, there's nested data. I think that **smart-table** can see only outer array, it doesn't know how to treat nested array – Anatoly Aug 11 '15 at 14:29
  • No it wouldn't, a table is a flat structure, so you would need to flatten your array. Without seeing expected results is hard to help more – charlietfl Aug 11 '15 at 14:39
  • @charlietfl, data sample I've provided it's my json. I'm expecting that every `position` object will be represented by **row** (header) and every nested items in a position by rows too. So, for my json it should be 5 rows in total. 3 rows for first position (position title itself + 2 items) and 2 rows for second position (position title + 1 item) – Anatoly Aug 11 '15 at 14:43
  • @charlietfl, so according to what you have said `a table is a flat structure, so you would need to flatten your array`, my only choice is to create another data model where I should maintain representation for my table? – Anatoly Aug 11 '15 at 14:45
  • Seems like simplest solution, yes. Can keep references to objects in existing structure if needed also – charlietfl Aug 11 '15 at 14:51

0 Answers0