[Editor] How to hide field on [Map CSV fields]?
[Editor] How to hide field on [Map CSV fields]?

I'm trying to hide a field on this modal?
selectEditor.create({
title: 'Map CSV fields',
buttons: 'Import '+csv.length+' records',
message: 'Select the CSV column you want to use the data from for each field.'
});
How do I do it?
I have only been able to hide a field on but not on selectEditor.create()
editor.on('initCreate', function() {
editor.show(); //Shows all fields
editor.hide('FirstName');
});
THANKS!
This discussion has been closed.
Answers
Your question is presumably related to this example?
The columns used for the mapping are added by this block:
so if you didn't want a column, you could add an
if
condition in there to not add it.Allan
Correct, But I still need that excluded field on the "edit" as well as in the table
Yep, so on the
initEdit
you would remove that field withfield().hide()
. That would do the trick,Colin
Thanks a lot, Colin, one last question, How would you add an if statement in the for loop to exclude 'phoneNumber' field from the .add()?
SOLUTION:
var selectEditor = new $.fn.dataTable.Editor();
var fields = editor.order();
const filteredArray = fields.filter((fields) => fields !== 'gender')
console.log(filteredArray) <--- new array:: HAY!
for ( var i=0 ; i<filteredArray.length ; i++ ) {
var field = editor.field( filteredArray[i] );
selectEditor.add( {
label: field.label(),
name: field.name(),
type: 'select',
options: header,
def: header[i]
} );
}