Replace Placeholder on text type - yadcf

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

Related

How to change text to value in data tables

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]

yadcf - multi_select with select2 - options dropdown not case sensitive

Will be posible, in yadcf multi_select filter, sort possible option with case insensibility?
Here is my fiddle to explain this.
In column STATUS are 4 possible values: "abs", "off", "OFF" and "ON". In dropdown the options appears in this order: "OFF", "ON", "abs", "off". And my desire is the options appears in this order: "abs", "OFF", "off", "ON".
Thanks in advance one more time.
You can provide you own custom sort function, , use the following attributes for the column sort_as: 'custom', sort_as_custom_func: mySort (where mySort is a sorting function, like this
'use strict';
var oTable = $('#example').DataTable();
var mySort = function(a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
};
yadcf.init(oTable, [
{
column_number: 0,
filter_type: 'multi_select',
filter_match_mode: 'exact',
select_type: 'select2',
sort_as: 'custom',
sort_as_custom_func: mySort
},{
column_number: 1,
filter_type: 'text',
}
]);
working jsfiddle

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

Populate data with custom function

How can I add custom filter options AND all the other data to a custom function?
Below is my code. I would like to have Yes and No filters, but also filters for all the other values in the column.
{column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},
You should use the append_data_to_table_data option for your filter
From docs:
append_data_to_table_data
Required: false
Type: string
Default value: undefined
Possible values: before / sorted
Description: Use 'before' to place your data array before the values that yadcf grabs from the table
use 'sorted' to place the data array sorted along with the values that yadcf grabs from the table
Note: 'sorted' option will have affect only if you data is an array of primitives (not objects)
So eventually your code will look like this
{
append_data_to_table_data: 'before',
column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},

Uncaught Error: Syntax error, unrecognized expression in Yadcf select type

I am having a problem with select type in Yadcf. It does not allow brackets.
I have this code
{
column_number: 9,
filter_type: 'select',
select_type: "select2",
column_data_type: "html",
html_data_type: "text",
filter_match_mode: "exact",
filter_default_label: "Select status",
},
HTML:
<td>Identified (In progress)</td>
So when page is loaded I have the error
Uncaught Error: Syntax error, unrecognized expression: Identified (In progress)
If I remove brackets select filter works fine and if I write
column_data_type: "text",
The error is gone but I can't filter by this value.
You should set the column_data_type to html only when the content of your <td> elements contains html code, for example <td><span>Identified (In progress)</span></td> and then yadcf will extract the Identified (In progress) from your span.
In you example the content of the <td> is a plain text, so you should declare the column_data_type at all because the default value of column_data_type is text , b.t.w the default of the [html_data_type is text]2 , so you shouldn't set its value too.
So just remove the
column_data_type: "html",
html_data_type: "text",
and it should work as expected
Here is a working jsfiddle (using latest beta version)
yadcf.init(oTable, [{
column_number: 0,
select_type: "select2",
select_type_options: {
width: '200px'
},
filter_match_mode: "exact"
}]);
p.s I'm the author of yadcf plugin
Seems like a bug in yadcf.
Try to use filter_match_mode: "contains" and column_data_type: "text", as shown below:
{
column_number: 9,
filter_type: 'select',
select_type: "select2",
column_data_type: "text",
filter_match_mode: "contains",
filter_default_label: "Select status"
},
See this JSFiddle for demonstration.