I'm very new to AngularJs and datatables. I have a requirement to populate the data in table rows using ng-repeat. Iam able to populate the rows and enabling the sorting for the first time. When i click on the arrows to sort ascend or descend the row data wiping off.
Here is my table data
<table datatable="ng" id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th class="col1">Campaign Name</th>
<th class="col4">Description</th>
<th class="col5">Activate/Deactivate</th>
<th class="col5">edit</th>
<!-- <th class="col5">status</th> -->
<!-- <th class="col5">Details</th> -->
</tr>
</thead>
<tbody >
<tr ng-repeat="campaign in campaignListData">
<td>{{campaign.campaignObject.campaignName}}</td>
<td>{{campaign.campaignObject.campaignMessage}}</td>
<td><button type="button" class="pay-amount pending" style="margin-top:-10px;margin-right:17px;width:128px;height:34px"
value = "{{ campaign.campaignObject.label }}" title="ACTIVATE" ng-click="updateCampaignStatus(campaign.campaignObject.id)">
<span style="margin-left:-10px;margin-right:17px;width:128px;height:34px">{{ campaign.campaignObject.label }}</span>
</button>
</td>
<td><a href="<c:url value="${contextPath}/merchant/manageCampaign/editCampaignConfiguration"/>?campaignId={{ campaign.campaignObject.id }}">
<img class="tableImage" style="margin-left:-8px;margin-top:-10px;" src="<c:url value="/resources/images/setting.png" />" ></a>
</td>
</tr>
</tbody>
</table>
Here is my sorting javascript code
<script type="text/javascript">
$(document).ready(function() {
$("#noCampaignData").hide();
//$("#example_paginate").hide();
var rowCount = $("#example tr").length;
console.log("Row count value is"+rowCount);
if (rowCount >= 0) {
console.log("Entered into Sorting");
$("#example").dataTable({
"pagingType" : "full_numbers",
"order" : [ [ 2, "desc" ] ]
});
}
});
</script>
I'm getting rowcount for tr is 1
I have the js file included at the bottom of the page
<script src="<c:url value="/resources/js/CampaignListController.js" />"></script>
<script src="<c:url value="/resources/js/jquery.dataTables.min.js" />"></script>
When Im loading data its fine loading with ng-repeat. But when i click on header to sort ascending or descending, rows are wiped off.
Please advise me where i'm doing wrong? I'm unable to sort the data ascending, descending and pagination is not at all working.
Sorry for my English.