please resolve below queries.
please resolve below queries.
Need answer of below questions
1) Want to print "100.00" instead of 100 in Amount field under data table. Means want to add extra '.00' with data. (Line No 51)
2) want to change alignment from left to right. only for Balance filed data. into data table. (Line No 50)
3) Want to print 'code' value to messageTop which is return from ajax result . currently it print '0'. (Line No 43)
4) When ajax return null, I want to show 'No Data Fount' but currently its loading, nothing is showing, Need to refresh data for next action.
data = [{"id":"1","Code":"123","balance":"100","amount":"1000"},{"id":"2","Code":"123","balance":"200","amount":"3000"}, {"id":"3","Code":"123","balance":"400","amount":"6000"}]
1. function validateform(){
2. var code = '0';
3. $('#rpt_table').DataTable( {
4. dom: 'Bfrtip',
5. fixedHeader: true,
6. colReorder: true,
7. responsive: true,
8. sPaginationType: "full_numbers",
9. bLengthChange: true,
10. order: [[ 0, 'asc' ]],
11. aLengthMenu: [[5, 10, 15, 20, -1], [5, 10, 15, 20, , "All"]],
12. working properly
13. iDisplayLength: 5,
14. aaSorting: [1, 'asc'],
15. bProcessing: true,
16. initComplete: function( settings, json ) {
17. $('div.loading').remove();
18. },
19. ajax: function (data, callback, settings) {
20. $.ajax({
21. url: "url",
22. type: "POST",
23. cache: false,
24. data: jsonData,
25. contentType: "application/json;",
26. dataType:"json"
27. }).done(function(response) {
28. code = response[0].Code; ** //want to print this value to messageTop**
29. callback({
30. draw: response.draw,
31. data: response,
32. recordsTotal: response
33. });
34. }).fail(function(err){
35. console.error('error...', err);
36. });
37. },
38. buttons: [
39. {
40. extend: 'excelHtml5',
41. title: 'My PDF',
42. messageTop:'Code'+code, **//question 3**
43. titleAttr: 'Excel'
44. }
45. ],
46. columns: [
47. {data: 'id'},
48. {data: 'code'},
49. {data: 'balance'}, ** //question 2**
50. {data: 'amount'} ** //question 1**
51. ]
52. });
53.
54. }
Replies
Allan
@allan thank you so much for your quick support. I am able to resolve 2, 3 & 4 queries. But question no 1 is still open. could you please help me with specific example.
@allan resolved with below solution
render: DataTable.render.number( null, null, 2, 'Rs. ' )
Great to hear you got it working.
Allan