Editor select field options filtering/disabling

Editor select field options filtering/disabling

resqonlineresqonline Posts: 45Questions: 10Answers: 0

For a dropdown select field in Editor I am using an ajax call to get user ids as select options - works great, however if one user id is selected and saved I want it not to appear in the select when I edit/add another item in Editor.
However, if I remove the option from the select, I am having trouble with already existing items that have saved user ids in their data.
How can I make sure, the data is only saved once per item and is not available to be chosen? So it's a unique selection and a user id is only connected to one item.

This is my ajax call to get the select field options set up:

    url: datatablesajax.url,
    data: {
        action: 'getusers',
    dataType: "json",
    success: function(data){
        var option = {};
        $.each(data, function(i, e){
            option.label = e.label;
            option.value = e.value;
            option = {};


  • rf1234rf1234 Posts: 2,627Questions: 80Answers: 379

    If you are using single edit (i.e. not editing multiple records at a time) the solution is simple. You can
    a) do the ajax call and the update of the options on "select" (data tables "select" event handler), or
    b) do that on "open" (editor "open" event handler).

    An extra asynchronous ajax call doesn't hurt performance. And this way you would always read the options AFTER the last update.

Sign In or Register to comment.