Two editors for same table

Two editors for same table

klinglerklingler Posts: 90Questions: 42Answers: 2

Good sunny afternoon (o;

I've setup a table which shows a product list of an online shop...and also bound an editor to it to modify, create and delete certain products...

Let's say when I want a different editor for a custom button which shows then a much simpler dialog...

Can I just define two editors and use in the datatables setup something like:

            { extend: "remove", editor: editor },
            { extend: "selected", editor: anothereditor }

But then I guess the two "create, edit, remove" definitions for each editor would collide with the one table..

thanks in advance
richard

Answers

  • rf1234rf1234 Posts: 2,947Questions: 87Answers: 416
    edited April 2020

    You can have dozens of editors if you like and lots of custom buttons ...
    This is from my own coding:

    buttons: [
        {   extend: "create", editor: contractEditor },
        {   extend: "edit",   editor: contractEditor },
                    "createProlongation",
                    "copyContract",
        {   extend: "editDescription", editor: contractDescriptionEditor },
        {   extend: "editComments", editor: contractCommentsEditor },
        {   extend: "remove", editor: contractEditor },
                    "copyInfomaSettingsSingle",
                    "editInfomaSettingsSingle",
                    "contractFiltrs",
                    "showHideAllChildRows",
        {   extend: "colvis", columns: ':not(.never)' },
        {   extend: "showAll", className: "showAllContractTable" }
    
    ]
    

    and one of the custom buttons which just edits the description field that is part of the "contract" data table with a richt text editor (quill in my case).

    $.fn.dataTable.ext.buttons.editDescription = {
        extend: 'edit',
        text: "Create / Edit Description"
        name: "editDescriptionButton"
    };
    

    I guess this individual custom button would also work instead of creating the reusable custom button:

     {  extend: "edit", editor: contractDescriptionEditor, 
        text: "Create / Edit Description", name: "editDescriptionButton",
        className: "thoseOtherButtons" },
    
This discussion has been closed.