locked
angularjs - other way to view grouped data by date in single tr ? RRS feed

  • Question

  • User-1846805900 posted

    Hi

    i try to group data i got by date and pass rowspan dynamically to view it in final as:

    i use this html to get data in final result:

            <table class="table table-bordered">
                <thead>
                    <tr class="text-center">
                        <td>الشهر</td>
                        <td>العميل</td>
                        <td>المدينة</td>
                        <td>النوع</td>
                        <td>التاريخ</td>
                    </tr>
                </thead>
                <tbody ng-repeat="customer in CustomerByMonth">
                    <tr ng-repeat='cust in customer | filter:searchText'>
                        <td ng-if="$first" rowspan="{{customer.length}}" class="text-center">
                            {{cust.MirageDate | date: 'yyyy-MM'}}
                        </td>
                        <td>{{cust.CustomerName}}</td>
                        <td class="text-center">{{cust.City.CityName}}</td>
                        <td class="text-center">{{cust.Type.TypeName}}</td>
                        <td class="text-center">{{cust.MirageDate | date: 'yyyy-MM-dd'}}</td>
                    </tr>
                </tbody>
            </table>

    angularjs code is:

            promiseGetCustomer.then(function (data) {
                var dataByMonth = {};
                data.data.forEach(itemToMonth);
                $scope.CustomerByMonth = dataByMonth;
    
                function itemToMonth(item) {
                    item.MirageDate = new Date(item.MirageDate)
                    var month = item.MirageDate.getMonth();
                    var year = item.MirageDate.getFullYear();
                    dataByMonth[year + '-' + month] = dataByMonth[year + '-' + month] || [];
                    dataByMonth[year + '-' + month].push(item);
                }
            },
                  function (errorPl) {
                      $scope.error = errorPl;
                  });

    i try to do pagination many times but all failed each time reason was that i use more than one tbody & i try to use ng table but pagination not working too - it seems that pagination works on single tr

    sample project is here: http://plnkr.co/edit/hr9zj6WMW0G6oRWOxC63?p=preview

    so please how can i make this scenario with one tr foreach row "i mean first row is single tr but it has 4 tr inside it .... ect "?

    or if any one can tell me how can i make ngtable pagination work with my table in the sample on plunker

    Monday, July 6, 2015 4:43 AM

Answers

  • User-1846805900 posted

    Thanks Krunal

    i did it using ngtable - and it works fine now

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 12, 2015 8:10 PM

All replies

  • User1644755831 posted

    Hello a.amin,

    AngularJS is third party framework and since this is asp.net forums You could post your question at https://groups.google.com/forum/#!forum/angular for more better response.

    Regards,

    Krunal

    Tuesday, July 7, 2015 9:37 PM
  • User-1846805900 posted

    Thanks Krunal

    i did it using ngtable - and it works fine now

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 12, 2015 8:10 PM