Display dropdown list options based on radio button selected value in editor form

Display dropdown list options based on radio button selected value in editor form

BTalayiBTalayi Posts: 18Questions: 4Answers: 0
edited March 2020 in Editor

Hi All,

Sorry if I ask a repetitive question.

I have a client side editor and in the editor form I need to update dropdown list options based on the selected value of radio button. I found dependent fields example but in my case I don't want to hide any fields.

How should I change this function to wrok in a way that I want?

Thank you for your help.

Replies

  • Ivse05Ivse05 Posts: 23Questions: 7Answers: 0
    edited March 2020

    Hi, I don't know if I got you right, but, if your edited fields depend on some other fields or data in the same row, you can add editable fields dynamically.

    Specify in editor options the field you want to edit

    fields: [
                {label: 'Id', name: 'Id'},
                {label: 'Dependent_Field', name: 'Dependent_Field'},
          
              ]
    
    

    On window load you can do

          editor.on('initEdit', function (e, node, data) {
          //data - your row full data, you can use it in your fields that you add dynamically
          //clear field with name Dependent_Field to add some new functionality to it
           editor.clear('Dependent_Field');
           editor.add(
           {
           //add field again but of "select2" type
            label: Dependent_Field,
            name: Dependent_Field,
            type: "select2",
            opts: {  
                ajax: {
                   //take value of your first field with name Id from row data
                    url: ur + data.Id,
                    type: "GET",
                    dataType: "json",               
                    processResults: results: $.map(data, function (serverData) {
                            return {
                                id: serverData.id,
                                text: serverData.rusName
                            };
                        }),
                },
            }
                );
            });
    

    Editor on event "initEdit" adds new field with type "select2" and it takes data from another field in the same row. Is that was what you wanted?

This discussion has been closed.