object function in editor name

object function in editor name

yu yen kanyu yen kan Posts: 65Questions: 31Answers: 0

I have an object

function obj(array){
    this.array = array;
    this.array_id_list = function(){
        var data = [];
        for (var i = 0; i < this.array.length; i++) {
            data.push(array[i]['id']);
        }

        return data;
    }
}

and an editor

var editor = new $.fn.dataTable.Editor( {
                    table: "#table",
                    idSrc:  'id',
                    fields: [  {
                            label: "array:",
                            name: "array_id_list",
                            multiple: true,
                            type: "select",
                            options: [{ label : "abc", value: "1"}, { label: "bcd", value: "2"} ]
                        }
                    ]
                });

but when I edit, the array is not selected at all, why?

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    I don't see how obj is being used. Could you give me a link to a page showing the issue please.

    Thanks,
    Allan

  • yu yen kanyu yen kan Posts: 65Questions: 31Answers: 0
    var data = new Array();
    
    for(var i = 0; i < 5;i ++){
        data[i] = new obj(i);
    }
    
    var table= $('#table).DataTable({
                        dom: "Bfrtip",
                        data: data,
                        select: true,
                        columns: [
                            { data: 'array[, ].id, title: "Array id" }
                        ],
                        buttons: [
                            { extend: "create", editor: editor},
                            { extend: "edit", editor: editor},
                            { extend: "remove", editor: editor}
                        ]
                    });
    
  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    Rather than having two conversations about the same thing, let's merge into this one which has more detail. Closing this thread.

    Allan

This discussion has been closed.