How to change text to value in data tables - datatables

Hi I am trying to export my values into excel but some of them are converting to text I don't know why I am passing integers but the exported excel file is converting them into integer. Is there any way to convert them into integer ?
table = $('#OriTable').dataTable({
responsive: false,
orderClasses: false,
aaData: json["data"],
deferRender: true,
stateSave: true,
bPaginate: false,
searching: false,
aaSorting: false,
dom: 'Bfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
]
});
Thanks.
Update
Attached the image below:
https://i.stack.imgur.com/PnDYR.png
data examples:
[1, "Finca", 6.371, 2378167.48, 0.13]
[2, "Diner", 5.573, 75643343.6, 4.27]

Related

Replace Placeholder on text type

I'm wondering if it's possible to replace the placeholder text of an input..
yadcf.init(myTable, [
{column_number : 0, filter_type: "text", case_insensitive: true, filter_container_id: "pokedex-number-filter", filter_reset_button_text: false, style_class: "form-control"},
{column_number : 1, filter_type: "text", case_insensitive: true, filter_container_id: "pokemon-name-filter", filter_reset_button_text: false, style_class: "form-control"},
{column_number : 2, filter_type: "text", case_insensitive: true, filter_container_id: "pokemon-gen-filter", filter_reset_button_text: false, style_class: "form-control"},
]);
You can user the following
* setDefaults
Description: Set global defaults for all yadcf instances.
Arguments: Object consisting of anything defined under "Global Parameters"
Usage example: yadcf.setDefaults({'language': {'select': 'تحديد قيمة'}});
or you can set per single table, per column using the filter_default_label option
read more inside the yadcf js file

Remove search box with bFilter still set to True in DataTable

I need to apply custom filtering function in my datatable. For this, I need to set "bFilter": true. But I don't need search box. How can I do that?
var holiday_filter = $('#holiday_table').DataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bSort": false,
"bInfo": false,
"order": [[0, 'desc']],
//"aLengthMenu": [5, 10, 20, 30],
'iDisplayLength': 4,
"bAutoWidth": false
});
Use dom option (default value lfrtip) without f which represents filtering input.
For example:
var holiday_filter = $('#holiday_table').DataTable({
// ... skipped ...
'dom': 'lrtip'
});

How to format Data Table exported to pdf?

Please help me to add CSS to the export PDF using Data Table. The exported PDF is not formatted as the HTML table.I need to make td align right in exported pdf.Also how can I merge columns?
Thank you
Here is my code:
$('#reporTable').DataTable({
"paging" : false,
"ordering": false,
"info" : false,
"searching" : false,
dom: 'T<"clear">lfrtip',
tableTools: {
"sSwfPath": "/javascripts/js/dataTables/tools/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "pdf",
"sTitle": $filename,
"sPdfOrientation": "landscape",
"sPdfMessage": $out_name+":" + msg
},
],
}
});
Use exportOptions of data table.
For details, please visit data table formatting
Follow this links for Customisation of the datatable buttons
https://datatables.net/extensions/buttons/examples/initialisation/className.html
https://datatables.net/extensions/buttons/examples/print/customisation.html

yadcf not sorting dropdown list properly

I have tried every option I can think of in configuring both DataTables (capital D) and yadcf but cannot seem to get the select drop down list to list in case-insensitive order.
Setup:
var dTable=$('#bTable').DataTable({
"traditional": false,
"pageLength": 1000,
"jQueryUI": true,
"stateSave": true,
"stateDuration": 60 * 60 * 24,
"processing": true,
"stateLoadParams": function (settings, data) {
lastSearch=data.search.search;
},
"ordering": true,
"processing": true,
"paging": false,
"info": false,
"autoWidth": false,
})
yadcf.init(dTable,[
{column_number : 3, column_data_type: "text", filter_match_mode: "exact", sort_as: "alphaNum", filter_container_id: "hs_clu", filter_reset_button_text: false, style_class: "select-style", filter_default_label: "All"},
],
{ cumulative_filtering: true }
);
When I click on the column header the column data is sorted properly as:
nbmps01
nbmps02
nbmps800
Network-1
Network-2
Network-3
NTPROV
NTSYM
NTWKTRANS
NVAM-CXMT
My dropdown select list is in this order and doesn't seem to be proper:
NTPROV
NTSYM
NTWKTRANS
NVAM-CXMT
Network-1
Network-2
Network-3
nbmps01
nbmps02
nbmps800
I have am at my wits end on this after 2 days of fiddling with it. Does anyone out there have any ideas and are willing to share.
Any help is very much appreciated.
I have improved the alpha numeric sorting in yadcf 0.9.1.beta.5 , now it works as expected.
use sort_as: "alphaNum"
Here is a working jsfiddle link

Dojo charting: How do you return an error if the chart is empty?

I'm pulling information from a database and putting it into a dojo chart. I'm trying to figure out how to return a 'no data message' with the way this chart is working:
var chart1 = new dojox.charting.Chart2D("traffic");
chart1.addPlot("default", {type: "Columns", gap: "15"});
chart1.addAxis("x", {minorTicks: false, font: "normal normal bold 9pt Arial",
labels: [{value: 1, text: 'Monday'},{value: 2, text: 'Tuesday'},{value: 3, text: 'Wednesday'},{value: 4, text: 'Thursday'},{value: 5, text: 'Friday'},{value: 6, text: 'Saturday'},{value: 7, text: 'Sunday'}]});
chart1.addAxis("y", {vertical: true, minorTicks: false, min: 0, font: "normal normal bold 12pt Arial"});
chart1.addSeries("Series 1", [<?php echo $trafficseries; ?>]);
chart1.setTheme(dojox.charting.themes.PlotKit.blue);
chart1.addPlot("Grid", {
type: "Grid",
hAxis: "x",
vAxis: "y",
hMajorLines: true,
hMinorLines: false,
vMajorLines: false,
vMinorLines: false
});
var anim_t = new dojox.charting.action2d.Tooltip(chart1, "default");
chart1.render();
Where would I add some sort of error handling if the data was empty?
Check, if your data has no points, and overlay a <div> over a chart with "no data" message. Otherwise hide it.