Cell Editor Type

Cell Editor Type

firstsoftwarefirstsoftware Posts: 3Questions: 1Answers: 0

Is it possible to set the editor type based on row instead of column, format is
field_name, value
where the value type is based on the field name, there is only 2 columns

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin
    Answer ✓

    I'm afraid not. The fields.type option is not configurable via the API - it can only be set at initialisation time or when the field is added to the form.

    If you want to change a field's type dynamically you would need to remove it using clear() and then add() to add a new field of the required type.

    Allan

  • firstsoftwarefirstsoftware Posts: 3Questions: 1Answers: 0

    Thanks for the quick reply.

  • firstsoftwarefirstsoftware Posts: 3Questions: 1Answers: 0
    edited April 2017

    If it helps anyone the following appears to work for setting editor based on row type

        customRowEditor.on( 'key-focus', function ( e, datatable, cell ) {
          editor.clear( 'custcell' ); // name of column for editor which needs to be removed
          var fieldtype = datatable.row(cell.index().row).data().fieldname; // field display type
          if (fieldtype =='Date')
        editor.add( {type: "datetime",name:"custcell",label: "custcell"});
          else if (fieldtype =='select')
        editor.add( {type: "select",name:"custcell",label: "custcell",options:[1,2,3]});
          else if (fieldtype =='text')
        editor.add( {type: "ckeditor",name:"custcell",label: "custcell"});
          else // display default input
        editor.add( {name:"custdata",label: "custcell"});
          editor.inline( cell.index());
    
        } );
    
This discussion has been closed.