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

[ Editor ] - Field2 depending on field1 input

$
0
0

I have one field (field2) which value depends on another field (field1).
Basically, when field1 changes, the values from field2 will need to be updated, as they depend on field1.

I assume that there are 2 ways to achieve this:

  1. detecting onChange
  2. configure a dependent field

Detecting onChange

    editor.field('field1').input().on('change', function (e, d) {
        if ( d && d.editor ) return;
        //Code to change field2 according to field1 value ($(this).val())
    });

configure a dependent field

           editor.dependent( 'field1', function ( val ) {
               //Code to change field2 according to field1 value (val)
            } );

I'm using the following versions:
Jquery: 1.12.4
Datatables: 1.10.16
Editor: 1.7.3
KeyTables: 2.4.0-dev
Select: 1.2.5

I have two specific questions:

  1. Which is the best approach?
  2. On method 1), using onChange, the value for d.editor is ALWAYS true, even if i the user changed the value

Thank you very much.


Viewing all articles
Browse latest Browse all 82293

Trending Articles



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