Editor node.js - Editing multiple columns and use value from another column to set a column?
Editor node.js - Editing multiple columns and use value from another column to set a column?
I use .on('preEdit') ... to set a value of a column ('title'). The value I use is from another column ('name'), that I transform. It works fine if I edit one column. But if I edit multiple columns ... the same value gets inserted for all edited columns.
How can I edit and set a value from another column if I want to edit multiple columns at once? That's the part:
.fields(
new Field( 'groups.group_id' ),
new Field( 'groups.name' ),
new Field( 'groups.title' )
)
.on( 'preEdit', (editor, id, values) => {
slugifyName = slugify(values.groups.name);
console.log(values.groups.name);
console.log(slugifyName);
editor
.field( 'groups.title' )
.setValue( slugifyName );
})
In console I see though it distinguishes between the columns?
Output Console:
ABC - Documents History
abc-documents-history
ABC - Documents
abc-documents
This discussion has been closed.
Answers
Hi @Capamania ,
You can use
field().multiSet()
ormultiSet()
and pass unique values for each of those records,Cheers,
Colin
Hi Colin,
multiSet() is not working on serverside ... I'm getting
TypeError: editor.field(...).multiSet is not a function
Can you please advise on how to set multiple values on serverside?
Hi @Capamania ,
multiSet()
is a client-side Editor method. I'm not sure if there's an easy way to do it on the server. Does the client edit multiple records and send those details through?Cheers,
Colin
I tried client side, but I'm phasing two issues. That's what I have so far:
It works if I just edit it without any changes.
But first issue:
If I only select one value ... the path inserted in the database is the converted previous title value. So not the altered value.
Second issue:
If I create a new record ... (and I set the path column to be not empty) ... I get error message:
How can I fetch the title value and alter the patch record before it gets inserted/submitted ?
I think I got it. initSubmit https://editor.datatables.net/reference/event/initSubmit seems to solve the issues.
Thanks.