Create a plugin for the datatable editor?

Create a plugin for the datatable editor?

klermannklermann Posts: 277Questions: 67Answers: 1
edited August 2017 in Free community support

Hello Allan, could you describe me how I can do to get an object inside another object to insert into the select type field, I do not want it to make logic, I do not want it to give me the script, I need to know for ex:

First step: In the editor I call a function listObject () - > {name: "minhasContas.nome", placeholder: 'Contas', "type": "select", "options": listObject() },

Second step: in the function I create a list - >
function listObject() {
var list = new Array();
list.push(["Item 1"]);
list.push(["Item 2"]);
list.push(["Item 3"]);
};

Third step: In the function I create an object that loads by ajax the list that I need inside the select type field.
Is this order to create a plugin for the datatable editor?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Could you explain to me a little about how you want to use this - ideally with screenshots of what you want? I don't really understand the point about using an array inside the array of options or what the goal there is. Why would you want to use an inner array?

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    My goal was this:

    `function listMinhasContas(){

                var listMC = new Array();
    
                listMC[0] = { "label": "Conta 1", "value": "1" };
                listMC[1] = { "label": "Conta 2", "value": "2" };
                listMC[2] = { "label": "Conta 3", "value": "3" };
                listMC[3] = { "label": "Conta 4", "value": "4" };
    
                return listMC;
            };`
    

    and in the editor:
    { name: "minhasContas.nome", placeholder: 'Contas', "type": "select", "ipOpts": listMinhasContas() },

    I need to load my my a list of objects that is inside my json that loads on the table

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    That looks more like it to me. Use editor.field('minhasContas.nome').update( ... ); to update the list of options.

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1
    edited August 2017

    Do you have an example? Do you have an example? I do not know how to implement!

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    The select field has some example code showing how update() can be used.

    Its basically what I showed above - you give field() the field name you want to update the options of and update() the list of options.

    Allan

This discussion has been closed.