Inline Editor select/select2 update problem in client side

Inline Editor select/select2 update problem in client side

ihuangmxihuangmx Posts: 26Questions: 9Answers: 1

In Editor client side Inline editor mode, I use select2 to fetch the data to update the field named 'good_id',like this

Datatable Columne
{
       title: name'',
       data: 'good_name',
       editField: 'good_id',
       defaultContent: 'please select good'
 }
Editor Field
{
                label: 'name:',
                name: 'good_id',
                type: 'select2',
                optionsPair: {
                    label: 'text',
                    value: 'id'
                },
                display: 'good.name',
                opts: {
                    allowClear: true,
                    dropdownAutoWidth:true,
                     delay:250,
                    ajax: {
                        url: goodUrl,
                        data: function (params) {
                            return {
                                search: params.term
                            }
                        },
                        processResults: function (data, params) {
                            return {
                                results :
                                    data.map(function(item) {
                                        return {
                                            id : item.id,
                                            text : item.name
                                        };
                                    }
                            )};
                        }
                    }
                }
            },

When I select a good, ' id : 1, text: 'aaa', I only can update the good_id field , but I want the good_name can be update as 'aaa', otherwise the td will display white because the good_name doesn't update , So please tell me how should I deal with this problem. All the editor event can only get the the id value not the text.

Answers

  • ihuangmxihuangmx Posts: 26Questions: 9Answers: 1

    I solve it

      get: function ( conf ) {
    
            var val = conf._input.val();
            if(conf.cacheLabel){
                sessionStorage.setItem('DTE_' + conf.data + '_' + val, conf._input.find('option:selected').text());
            }
            val =  conf._input.prop('multiple') && val === null ?
                [] :
                val;
              
            return conf.separator ?
                val.join( conf.separator ) :
                val;
        },
    
    xxxEditor.on( 'submitSuccess', function ( e, json, data) {
    
            var modifier = purchaseEditor.modifier();
    
            if(modifier.column == xxx){
            
                data.good.name = sessionStorage.getItem('DTE_good_id_' + data.good_id );
                xxxDt.row(modifier.row).data(data).draw();
    
            }
        
        });
    
This discussion has been closed.