With the commented code i was able call the data but when I move to the dataTable it doesn't work.
Code
Order No
Customer name
Order Phone
Sales Date
Update
File
@*
{{item.OrderNo}}
{{item.CustomerName}}
{{item.CustomerPhone}}
{{item.OrderDate}}
Edit
Delete
*@
Vishal JoshiRank #377 · 6.7K reputationPosted Feb 18, 2023, 2:49 AM EST
Hello
The code looks good with the help of $compile jquery data table columns render events will be bound to angular functions.
There is duplicate of below code.
"createdRow": function ( row, data, index ) { $compile(row)($scope); //add this to compile the DOM },it should be only indise juqery data table
i.e. inside $("#dataTable15").DataTable({ }}
So just remove duplicate code and it should work fine.
Thanks
Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Feb 17, 2023, 9:50 AM EST
(function () { //Angularjs contoller app.controller('HomeInvoiceList',[ function ($scope, $http,$compile, $filter) { $scope.Sale = new Object(); $scope.list = true; $scope.invoice = false; // declaring a global scope variable $scope.Delete = function(){ // Need to implement } $scope.ShowHideEdit = function() { $scope.list = $scope.list==true? false: true; $scope.invoice =$scope.invoice==true? false: true; } var init = function () { GetCart(); GetAllSales(); }; // end of ini "createdRow": function ( row, data, index ) { $compile(row)($scope); //add this to compile the DOM }, function bindDatatable(){ $("#dataTable15").DataTable({ "processing": false, "serverSide": false, "paging": true, "destroy": true, pageLength: 25, buttons: [ { extend: 'copy' }, { extend: 'csv' }, { extend: 'excel', title: 'ExampleFile' }, { extend: 'pdf', title: 'ExampleFile' }, { extend: 'print', customize: function (win) { $(win.document.body).addClass('white-bg'); $(win.document.body).css('font-size', '10px'); $(win.document.body).find('#dataTable15') .addClass('compact') .css('font-size', 'inherit'); } } ], dom: 'lTfgitp', "columns": [ { "data": "OrderNo" }, { "data": "CustomerName" }, { "data": "CustomerPhone" }, { "data": "OrderDate" }, { "data": "SalesId", "width": "50px", "render": function (item, SalesId) { return "Edit"; } }, { "data": "SalesId", "width": "50px", "render": function (data) { return "Delete"; } }, ], "createdRow": function ( row, data, index ) { $compile(row)($scope); //add this to compile the DOM }, "ajax": { "url": "/Home/GetAllSales", "type": "GET", "dataSrc": "[]", } }); } bindDatatable(); }]); }).call(angular);Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Feb 18, 2023, 7:55 AM EST
Thank you Vishal and Paul for your swift response,
I did as Vishal said and is working, thank you all guys
Tuhin PaulRank #7 · 71.9K reputationPosted Feb 17, 2023, 3:07 PM EST
The issue is with the commented out code block that was responsible for getting the data to be displayed in the DataTable. To fix this, you can try modifying the
GetAllSalesfunction to return the data in the required format for DataTables to display it properly.