Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82607

select2 editor plugin is breaking editor.add used in events like initCreate and initEdit

$
0
0

select2 editor plugin is breaking editor.add used in events like initCreate and initEdit.

I do not get error if I move prod_name in fields array in intialization, or if I do not use select2. Note that recently I had updated the https://editor.datatables.net/plug-ins/field-type/editor.select2#Plug-in-code, before that it was working.

The error that I get in console is Uncaught Unknown field name - prod_name.

        var editor = new $.fn.dataTable.Editor({
            ajax: "/mydata.php",
            table: "#dataTableBuilder",
            display: "bootstrap",
            fields: [
                {label: "Product Attribute:", name: "prod_attribute"},
                {label: "Attribute Content:", type: "textarea", name: "prod_attribute_content"},
            ]
        });

        editor.on('initCreate', function () {
            editor.add(
            {
               label: "Product Name:", 
               name: "prod_name", 
               className: 'required' , 
               type:'select2',
               opts:{
                            placeholder: 'Select a product',
                            minimumInputLength: 1,
                            ajax: {
                                url: '/searchbusinessproduct',
                                dataType: 'json',
                                data: function (params) {
                                    return {
                                        product_search: params.term,
                                        search_type: 'product_search',
                                        prod_id:$('#product_id').val()
                                    };
                                },
                                processResults: function (data) {
                                    return {
                                        results: data
                                    };
                                },
                                cache: true
                            },
                            escapeMarkup: function (markup) {
                                return markup;
                            },
                            templateSelection: formatState,
                    }
                }
            );
        });

Viewing all articles
Browse latest Browse all 82607

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>