Editor: Ajax filled form fields

Editor: Ajax filled form fields

netscreensnetscreens Posts: 1Questions: 1Answers: 0

I would like to enter an address in the Datatables Editor and Google Maps should be queried in the background. The determined coordinates should be saved in a second field.

I used the dependent feature from this Blogpost:
https://datatables.net/blog/2017-09-01

editor.dependent( 'map.street', 'php/get_coordinates.php' );

But this sample fills an select Inputfield with options.

I don't know the json syntax to put the determined coordinates in an textfield in datatables editor.

Hope someone can help me.

Thanks,
Tobias

Answers

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin

    Hi Tobias,

    The dependent() method's documentation can be difficult to read, because it has so many options! But basically you'll want to return an object to the callback something like this:

    cb({
      values: {
         field1: 'long',
         field2: 'lat'
      }
    });
    

    Another, and possibly easier option is just to call the Editor value methods once you've got the values you want:

    editor.field('field1').val(long);
    

    Doing a blog post on Editor integration with Google map address lookup is something that I've been meaning to do for a while - thanks for the reminder.

    Allan

Sign In or Register to comment.