Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3740

Dynamically Create Checkbox Items From Database Textarea Content

$
0
0

I have a textarea in my database which contains a comma separated list of values. These vary depending on the table row. Is it possible to create my checkbox items dynamically in editor from this comma separated string? Hardcoded it is working fine with a couple of test static values (see the field 'Exclude Real Time Blacklists'):

        var editor = new $.fn.DataTable.Editor({
            "ajax" : {
                "url" : "table.module.php",
                "type" : "POST",
                "data" : function(d) {
                    d.user_id = "126";
                }
            },
            "table" : "#module",
            "fields" : [
            {
                "label" : "Monitor Type",
                "name" : "monitor_type",
                "type" : "text"
            }, {
                "label" : "Monitor Name",
                "name" : "name",
                "type" : "text"
            }, {
                "label" : "Remark",
                "name" : "remark",
                "type" : "textarea"
            }, {            
                "label" : "Content Match",
                "name" : "string",
                "type" : "text"
            }, {               
                type:  "checkbox",
                label: "Exclude Real Time Blacklists (RBL's):",
                name:  "blacklist_exclude",
                options: {
                "UCEPROTECT BL1": "UCEPROTECT BL1",
                "Backscatterer":  "Backscatterer"
                },
                separator: ','                
            }, {
                "label" : "Status",
                "name" : "active",
                "type" : "select",
                "ipOpts" : [{
                    "label" : "Active",
                    "value" : "Active"
                    }, {
                    "label" : "Inactive",
                    "value" : "Inactive"                
                }]
            }]
        });

The database column currently holds data like so; Backscatterer,UCEPROTECT BL1

Can I use that data to create my checkbox options dynamically so they are different for each row of the table?

I think it is possible to use editor.get( 'blacklist_exclude' ) to access the content perhaps?

Many thanks

Chris


Viewing all articles
Browse latest Browse all 3740

Trending Articles