Automatically displays the option












3















I have this table, where I show a select with options but when clicking this it does not display the list right away. I have to click the input and then the list show.



How can I automatically show the list with just one click? Im using x-editable






$('#table').editable({
container: 'body',
selector: 'td.task',
title: 'task',
type: "POST",
showbuttons: false,
type: 'text',
validate: function(value) {
if ($.trim(value) == '') {
return 'Empty!';
}
},
success: function(response) {

$(this).parent().find(".Item").click();
}
});
var ITEM = ;
$.each({
"Item1": "Item1",
"Item2": "Item2",
"Item3": "Item3",
"Item4": "Item4"
}, function(k, v) {
ITEM.push({
value: k,
text: v
});
});

$('#table').editable({
container: 'body',
selector: 'td.Item',
title: 'Item',
type: "POST",
source: ITEM,
select2: {
width: 300,
placeholder: 'Item',
allowClear: true
},
validate: function(value) {
if ($.trim(value) == '') {
return 'Empty!';
}
}
});

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

<table id="table" class="table table-bordered">
<thead>
<tr>
<th>Id</th>
<th>Task</th>
<th>Item</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td data-name="task" class="task" data-type="text">001</td>
<td data-name="Item" class="Item" data-type="select2">Item2</td>
</tr>
<tr>
<td>2</td>
<td data-name="task" class="task" data-type="text">002</td>
<td data-name="Item" class="Item" data-type="select2">Item1</td>
</tr>
</tbody>
</table>





I hope I have explained well. Greetings!










share|improve this question





























    3















    I have this table, where I show a select with options but when clicking this it does not display the list right away. I have to click the input and then the list show.



    How can I automatically show the list with just one click? Im using x-editable






    $('#table').editable({
    container: 'body',
    selector: 'td.task',
    title: 'task',
    type: "POST",
    showbuttons: false,
    type: 'text',
    validate: function(value) {
    if ($.trim(value) == '') {
    return 'Empty!';
    }
    },
    success: function(response) {

    $(this).parent().find(".Item").click();
    }
    });
    var ITEM = ;
    $.each({
    "Item1": "Item1",
    "Item2": "Item2",
    "Item3": "Item3",
    "Item4": "Item4"
    }, function(k, v) {
    ITEM.push({
    value: k,
    text: v
    });
    });

    $('#table').editable({
    container: 'body',
    selector: 'td.Item',
    title: 'Item',
    type: "POST",
    source: ITEM,
    select2: {
    width: 300,
    placeholder: 'Item',
    allowClear: true
    },
    validate: function(value) {
    if ($.trim(value) == '') {
    return 'Empty!';
    }
    }
    });

    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

    <table id="table" class="table table-bordered">
    <thead>
    <tr>
    <th>Id</th>
    <th>Task</th>
    <th>Item</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>1</td>
    <td data-name="task" class="task" data-type="text">001</td>
    <td data-name="Item" class="Item" data-type="select2">Item2</td>
    </tr>
    <tr>
    <td>2</td>
    <td data-name="task" class="task" data-type="text">002</td>
    <td data-name="Item" class="Item" data-type="select2">Item1</td>
    </tr>
    </tbody>
    </table>





    I hope I have explained well. Greetings!










    share|improve this question



























      3












      3








      3








      I have this table, where I show a select with options but when clicking this it does not display the list right away. I have to click the input and then the list show.



      How can I automatically show the list with just one click? Im using x-editable






      $('#table').editable({
      container: 'body',
      selector: 'td.task',
      title: 'task',
      type: "POST",
      showbuttons: false,
      type: 'text',
      validate: function(value) {
      if ($.trim(value) == '') {
      return 'Empty!';
      }
      },
      success: function(response) {

      $(this).parent().find(".Item").click();
      }
      });
      var ITEM = ;
      $.each({
      "Item1": "Item1",
      "Item2": "Item2",
      "Item3": "Item3",
      "Item4": "Item4"
      }, function(k, v) {
      ITEM.push({
      value: k,
      text: v
      });
      });

      $('#table').editable({
      container: 'body',
      selector: 'td.Item',
      title: 'Item',
      type: "POST",
      source: ITEM,
      select2: {
      width: 300,
      placeholder: 'Item',
      allowClear: true
      },
      validate: function(value) {
      if ($.trim(value) == '') {
      return 'Empty!';
      }
      }
      });

      <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
      <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
      <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

      <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
      <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
      <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

      <table id="table" class="table table-bordered">
      <thead>
      <tr>
      <th>Id</th>
      <th>Task</th>
      <th>Item</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>1</td>
      <td data-name="task" class="task" data-type="text">001</td>
      <td data-name="Item" class="Item" data-type="select2">Item2</td>
      </tr>
      <tr>
      <td>2</td>
      <td data-name="task" class="task" data-type="text">002</td>
      <td data-name="Item" class="Item" data-type="select2">Item1</td>
      </tr>
      </tbody>
      </table>





      I hope I have explained well. Greetings!










      share|improve this question
















      I have this table, where I show a select with options but when clicking this it does not display the list right away. I have to click the input and then the list show.



      How can I automatically show the list with just one click? Im using x-editable






      $('#table').editable({
      container: 'body',
      selector: 'td.task',
      title: 'task',
      type: "POST",
      showbuttons: false,
      type: 'text',
      validate: function(value) {
      if ($.trim(value) == '') {
      return 'Empty!';
      }
      },
      success: function(response) {

      $(this).parent().find(".Item").click();
      }
      });
      var ITEM = ;
      $.each({
      "Item1": "Item1",
      "Item2": "Item2",
      "Item3": "Item3",
      "Item4": "Item4"
      }, function(k, v) {
      ITEM.push({
      value: k,
      text: v
      });
      });

      $('#table').editable({
      container: 'body',
      selector: 'td.Item',
      title: 'Item',
      type: "POST",
      source: ITEM,
      select2: {
      width: 300,
      placeholder: 'Item',
      allowClear: true
      },
      validate: function(value) {
      if ($.trim(value) == '') {
      return 'Empty!';
      }
      }
      });

      <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
      <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
      <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

      <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
      <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
      <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

      <table id="table" class="table table-bordered">
      <thead>
      <tr>
      <th>Id</th>
      <th>Task</th>
      <th>Item</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>1</td>
      <td data-name="task" class="task" data-type="text">001</td>
      <td data-name="Item" class="Item" data-type="select2">Item2</td>
      </tr>
      <tr>
      <td>2</td>
      <td data-name="task" class="task" data-type="text">002</td>
      <td data-name="Item" class="Item" data-type="select2">Item1</td>
      </tr>
      </tbody>
      </table>





      I hope I have explained well. Greetings!






      $('#table').editable({
      container: 'body',
      selector: 'td.task',
      title: 'task',
      type: "POST",
      showbuttons: false,
      type: 'text',
      validate: function(value) {
      if ($.trim(value) == '') {
      return 'Empty!';
      }
      },
      success: function(response) {

      $(this).parent().find(".Item").click();
      }
      });
      var ITEM = ;
      $.each({
      "Item1": "Item1",
      "Item2": "Item2",
      "Item3": "Item3",
      "Item4": "Item4"
      }, function(k, v) {
      ITEM.push({
      value: k,
      text: v
      });
      });

      $('#table').editable({
      container: 'body',
      selector: 'td.Item',
      title: 'Item',
      type: "POST",
      source: ITEM,
      select2: {
      width: 300,
      placeholder: 'Item',
      allowClear: true
      },
      validate: function(value) {
      if ($.trim(value) == '') {
      return 'Empty!';
      }
      }
      });

      <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
      <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
      <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

      <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
      <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
      <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

      <table id="table" class="table table-bordered">
      <thead>
      <tr>
      <th>Id</th>
      <th>Task</th>
      <th>Item</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>1</td>
      <td data-name="task" class="task" data-type="text">001</td>
      <td data-name="Item" class="Item" data-type="select2">Item2</td>
      </tr>
      <tr>
      <td>2</td>
      <td data-name="task" class="task" data-type="text">002</td>
      <td data-name="Item" class="Item" data-type="select2">Item1</td>
      </tr>
      </tbody>
      </table>





      $('#table').editable({
      container: 'body',
      selector: 'td.task',
      title: 'task',
      type: "POST",
      showbuttons: false,
      type: 'text',
      validate: function(value) {
      if ($.trim(value) == '') {
      return 'Empty!';
      }
      },
      success: function(response) {

      $(this).parent().find(".Item").click();
      }
      });
      var ITEM = ;
      $.each({
      "Item1": "Item1",
      "Item2": "Item2",
      "Item3": "Item3",
      "Item4": "Item4"
      }, function(k, v) {
      ITEM.push({
      value: k,
      text: v
      });
      });

      $('#table').editable({
      container: 'body',
      selector: 'td.Item',
      title: 'Item',
      type: "POST",
      source: ITEM,
      select2: {
      width: 300,
      placeholder: 'Item',
      allowClear: true
      },
      validate: function(value) {
      if ($.trim(value) == '') {
      return 'Empty!';
      }
      }
      });

      <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
      <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
      <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

      <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
      <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
      <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

      <table id="table" class="table table-bordered">
      <thead>
      <tr>
      <th>Id</th>
      <th>Task</th>
      <th>Item</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>1</td>
      <td data-name="task" class="task" data-type="text">001</td>
      <td data-name="Item" class="Item" data-type="select2">Item2</td>
      </tr>
      <tr>
      <td>2</td>
      <td data-name="task" class="task" data-type="text">002</td>
      <td data-name="Item" class="Item" data-type="select2">Item1</td>
      </tr>
      </tbody>
      </table>






      javascript html






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 12:40







      MoteCL

















      asked Nov 14 '18 at 12:33









      MoteCLMoteCL

      7110




      7110
























          4 Answers
          4






          active

          oldest

          votes


















          2





          +25









          From my understanding, you need to add the data-value attribute, I believe there is no other way.






          $('#table').editable({
          container: 'body',
          selector: 'td.task',
          title: 'task',
          type: "POST",
          showbuttons: false,
          type: 'text',
          validate: function(value) {
          if ($.trim(value) == '') {
          return 'Empty!';
          }
          },
          success: function(response) {

          $(this).parent().find(".Item").click();
          }
          });
          var ITEM = ;
          $.each({
          "Item1": "Item1",
          "Item2": "Item2",
          "Item3": "Item3",
          "Item4": "Item4"
          }, function(k, v) {
          ITEM.push({
          value: k,
          text: v
          });
          });

          $('#table').editable({
          container: 'body',
          selector: 'td.Item',
          title: 'Item',
          type: "POST",
          showbuttons: false,
          source: ITEM,
          validate: function(value) {
          if ($.trim(value) == '') {
          return 'Empty!';
          }
          }
          });

          <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
          <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
          <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
          <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

          <table id="table" class="table table-bordered">
          <thead>
          <tr>
          <th>Id</th>
          <th>Task</th>
          <th>Item</th>
          </tr>
          </thead>
          <tbody>
          <tr>
          <td>1</td>
          <td data-name="task" class="task" data-type="text">001</td>
          <td data-name="Item" class="Item" data-type="select" data-value="Item2">Item2</td>
          </tr>
          <tr>
          <td>2</td>
          <td data-name="task" class="task" data-type="text">002</td>
          <td data-name="Item" class="Item" data-type="select" data-value="Item1">Item1</td>
          </tr>
          </tbody>
          </table>








          share|improve this answer































            0














            You can either create your own data-type: example.



            Or another thing you can do, which does not show the list right away, but is less cumbersome: make the select inline. Change the editable for the select datatypes to this:



            $('#table').editable({
            container: 'body',
            selector: 'td.Item',
            title: 'Item',
            type: "POST",
            mode: 'inline',
            showbuttons: false,
            source: ITEM,
            validate: function(value) {
            if ($.trim(value) == '') {
            return 'Empty!';
            }
            }
            });


            Added mode:'inline'






            share|improve this answer































              0














              There's an issue with the select2 version 4, stating we cannot use input tags anymore.




              1. http://github.com/select2/select2/issues/3057

              2. https://github.com/vitalets/x-editable/issues/979


              It is recommended to use a <select> element, documentation for reference.



              Another link might be helpful for you






              share|improve this answer































                0














                There is an issue with select2.min.js in version 4. So , You needd to replace bellow link



                <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>


                with



                <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>





                share|improve this answer
























                • Thanks I didnt noticed

                  – MoteCL
                  Nov 24 '18 at 12:39











                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300364%2fautomatically-displays-the-option%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                2





                +25









                From my understanding, you need to add the data-value attribute, I believe there is no other way.






                $('#table').editable({
                container: 'body',
                selector: 'td.task',
                title: 'task',
                type: "POST",
                showbuttons: false,
                type: 'text',
                validate: function(value) {
                if ($.trim(value) == '') {
                return 'Empty!';
                }
                },
                success: function(response) {

                $(this).parent().find(".Item").click();
                }
                });
                var ITEM = ;
                $.each({
                "Item1": "Item1",
                "Item2": "Item2",
                "Item3": "Item3",
                "Item4": "Item4"
                }, function(k, v) {
                ITEM.push({
                value: k,
                text: v
                });
                });

                $('#table').editable({
                container: 'body',
                selector: 'td.Item',
                title: 'Item',
                type: "POST",
                showbuttons: false,
                source: ITEM,
                validate: function(value) {
                if ($.trim(value) == '') {
                return 'Empty!';
                }
                }
                });

                <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
                <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
                <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
                <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

                <table id="table" class="table table-bordered">
                <thead>
                <tr>
                <th>Id</th>
                <th>Task</th>
                <th>Item</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                <td>1</td>
                <td data-name="task" class="task" data-type="text">001</td>
                <td data-name="Item" class="Item" data-type="select" data-value="Item2">Item2</td>
                </tr>
                <tr>
                <td>2</td>
                <td data-name="task" class="task" data-type="text">002</td>
                <td data-name="Item" class="Item" data-type="select" data-value="Item1">Item1</td>
                </tr>
                </tbody>
                </table>








                share|improve this answer




























                  2





                  +25









                  From my understanding, you need to add the data-value attribute, I believe there is no other way.






                  $('#table').editable({
                  container: 'body',
                  selector: 'td.task',
                  title: 'task',
                  type: "POST",
                  showbuttons: false,
                  type: 'text',
                  validate: function(value) {
                  if ($.trim(value) == '') {
                  return 'Empty!';
                  }
                  },
                  success: function(response) {

                  $(this).parent().find(".Item").click();
                  }
                  });
                  var ITEM = ;
                  $.each({
                  "Item1": "Item1",
                  "Item2": "Item2",
                  "Item3": "Item3",
                  "Item4": "Item4"
                  }, function(k, v) {
                  ITEM.push({
                  value: k,
                  text: v
                  });
                  });

                  $('#table').editable({
                  container: 'body',
                  selector: 'td.Item',
                  title: 'Item',
                  type: "POST",
                  showbuttons: false,
                  source: ITEM,
                  validate: function(value) {
                  if ($.trim(value) == '') {
                  return 'Empty!';
                  }
                  }
                  });

                  <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
                  <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
                  <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
                  <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
                  <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

                  <table id="table" class="table table-bordered">
                  <thead>
                  <tr>
                  <th>Id</th>
                  <th>Task</th>
                  <th>Item</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr>
                  <td>1</td>
                  <td data-name="task" class="task" data-type="text">001</td>
                  <td data-name="Item" class="Item" data-type="select" data-value="Item2">Item2</td>
                  </tr>
                  <tr>
                  <td>2</td>
                  <td data-name="task" class="task" data-type="text">002</td>
                  <td data-name="Item" class="Item" data-type="select" data-value="Item1">Item1</td>
                  </tr>
                  </tbody>
                  </table>








                  share|improve this answer


























                    2





                    +25







                    2





                    +25



                    2




                    +25





                    From my understanding, you need to add the data-value attribute, I believe there is no other way.






                    $('#table').editable({
                    container: 'body',
                    selector: 'td.task',
                    title: 'task',
                    type: "POST",
                    showbuttons: false,
                    type: 'text',
                    validate: function(value) {
                    if ($.trim(value) == '') {
                    return 'Empty!';
                    }
                    },
                    success: function(response) {

                    $(this).parent().find(".Item").click();
                    }
                    });
                    var ITEM = ;
                    $.each({
                    "Item1": "Item1",
                    "Item2": "Item2",
                    "Item3": "Item3",
                    "Item4": "Item4"
                    }, function(k, v) {
                    ITEM.push({
                    value: k,
                    text: v
                    });
                    });

                    $('#table').editable({
                    container: 'body',
                    selector: 'td.Item',
                    title: 'Item',
                    type: "POST",
                    showbuttons: false,
                    source: ITEM,
                    validate: function(value) {
                    if ($.trim(value) == '') {
                    return 'Empty!';
                    }
                    }
                    });

                    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
                    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
                    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
                    <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
                    <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

                    <table id="table" class="table table-bordered">
                    <thead>
                    <tr>
                    <th>Id</th>
                    <th>Task</th>
                    <th>Item</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                    <td>1</td>
                    <td data-name="task" class="task" data-type="text">001</td>
                    <td data-name="Item" class="Item" data-type="select" data-value="Item2">Item2</td>
                    </tr>
                    <tr>
                    <td>2</td>
                    <td data-name="task" class="task" data-type="text">002</td>
                    <td data-name="Item" class="Item" data-type="select" data-value="Item1">Item1</td>
                    </tr>
                    </tbody>
                    </table>








                    share|improve this answer













                    From my understanding, you need to add the data-value attribute, I believe there is no other way.






                    $('#table').editable({
                    container: 'body',
                    selector: 'td.task',
                    title: 'task',
                    type: "POST",
                    showbuttons: false,
                    type: 'text',
                    validate: function(value) {
                    if ($.trim(value) == '') {
                    return 'Empty!';
                    }
                    },
                    success: function(response) {

                    $(this).parent().find(".Item").click();
                    }
                    });
                    var ITEM = ;
                    $.each({
                    "Item1": "Item1",
                    "Item2": "Item2",
                    "Item3": "Item3",
                    "Item4": "Item4"
                    }, function(k, v) {
                    ITEM.push({
                    value: k,
                    text: v
                    });
                    });

                    $('#table').editable({
                    container: 'body',
                    selector: 'td.Item',
                    title: 'Item',
                    type: "POST",
                    showbuttons: false,
                    source: ITEM,
                    validate: function(value) {
                    if ($.trim(value) == '') {
                    return 'Empty!';
                    }
                    }
                    });

                    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
                    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
                    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
                    <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
                    <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

                    <table id="table" class="table table-bordered">
                    <thead>
                    <tr>
                    <th>Id</th>
                    <th>Task</th>
                    <th>Item</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                    <td>1</td>
                    <td data-name="task" class="task" data-type="text">001</td>
                    <td data-name="Item" class="Item" data-type="select" data-value="Item2">Item2</td>
                    </tr>
                    <tr>
                    <td>2</td>
                    <td data-name="task" class="task" data-type="text">002</td>
                    <td data-name="Item" class="Item" data-type="select" data-value="Item1">Item1</td>
                    </tr>
                    </tbody>
                    </table>








                    $('#table').editable({
                    container: 'body',
                    selector: 'td.task',
                    title: 'task',
                    type: "POST",
                    showbuttons: false,
                    type: 'text',
                    validate: function(value) {
                    if ($.trim(value) == '') {
                    return 'Empty!';
                    }
                    },
                    success: function(response) {

                    $(this).parent().find(".Item").click();
                    }
                    });
                    var ITEM = ;
                    $.each({
                    "Item1": "Item1",
                    "Item2": "Item2",
                    "Item3": "Item3",
                    "Item4": "Item4"
                    }, function(k, v) {
                    ITEM.push({
                    value: k,
                    text: v
                    });
                    });

                    $('#table').editable({
                    container: 'body',
                    selector: 'td.Item',
                    title: 'Item',
                    type: "POST",
                    showbuttons: false,
                    source: ITEM,
                    validate: function(value) {
                    if ($.trim(value) == '') {
                    return 'Empty!';
                    }
                    }
                    });

                    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
                    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
                    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
                    <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
                    <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

                    <table id="table" class="table table-bordered">
                    <thead>
                    <tr>
                    <th>Id</th>
                    <th>Task</th>
                    <th>Item</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                    <td>1</td>
                    <td data-name="task" class="task" data-type="text">001</td>
                    <td data-name="Item" class="Item" data-type="select" data-value="Item2">Item2</td>
                    </tr>
                    <tr>
                    <td>2</td>
                    <td data-name="task" class="task" data-type="text">002</td>
                    <td data-name="Item" class="Item" data-type="select" data-value="Item1">Item1</td>
                    </tr>
                    </tbody>
                    </table>





                    $('#table').editable({
                    container: 'body',
                    selector: 'td.task',
                    title: 'task',
                    type: "POST",
                    showbuttons: false,
                    type: 'text',
                    validate: function(value) {
                    if ($.trim(value) == '') {
                    return 'Empty!';
                    }
                    },
                    success: function(response) {

                    $(this).parent().find(".Item").click();
                    }
                    });
                    var ITEM = ;
                    $.each({
                    "Item1": "Item1",
                    "Item2": "Item2",
                    "Item3": "Item3",
                    "Item4": "Item4"
                    }, function(k, v) {
                    ITEM.push({
                    value: k,
                    text: v
                    });
                    });

                    $('#table').editable({
                    container: 'body',
                    selector: 'td.Item',
                    title: 'Item',
                    type: "POST",
                    showbuttons: false,
                    source: ITEM,
                    validate: function(value) {
                    if ($.trim(value) == '') {
                    return 'Empty!';
                    }
                    }
                    });

                    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
                    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
                    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
                    <script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
                    <link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>

                    <table id="table" class="table table-bordered">
                    <thead>
                    <tr>
                    <th>Id</th>
                    <th>Task</th>
                    <th>Item</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                    <td>1</td>
                    <td data-name="task" class="task" data-type="text">001</td>
                    <td data-name="Item" class="Item" data-type="select" data-value="Item2">Item2</td>
                    </tr>
                    <tr>
                    <td>2</td>
                    <td data-name="task" class="task" data-type="text">002</td>
                    <td data-name="Item" class="Item" data-type="select" data-value="Item1">Item1</td>
                    </tr>
                    </tbody>
                    </table>






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 16 '18 at 14:34









                    silentwsilentw

                    2,85731939




                    2,85731939

























                        0














                        You can either create your own data-type: example.



                        Or another thing you can do, which does not show the list right away, but is less cumbersome: make the select inline. Change the editable for the select datatypes to this:



                        $('#table').editable({
                        container: 'body',
                        selector: 'td.Item',
                        title: 'Item',
                        type: "POST",
                        mode: 'inline',
                        showbuttons: false,
                        source: ITEM,
                        validate: function(value) {
                        if ($.trim(value) == '') {
                        return 'Empty!';
                        }
                        }
                        });


                        Added mode:'inline'






                        share|improve this answer




























                          0














                          You can either create your own data-type: example.



                          Or another thing you can do, which does not show the list right away, but is less cumbersome: make the select inline. Change the editable for the select datatypes to this:



                          $('#table').editable({
                          container: 'body',
                          selector: 'td.Item',
                          title: 'Item',
                          type: "POST",
                          mode: 'inline',
                          showbuttons: false,
                          source: ITEM,
                          validate: function(value) {
                          if ($.trim(value) == '') {
                          return 'Empty!';
                          }
                          }
                          });


                          Added mode:'inline'






                          share|improve this answer


























                            0












                            0








                            0







                            You can either create your own data-type: example.



                            Or another thing you can do, which does not show the list right away, but is less cumbersome: make the select inline. Change the editable for the select datatypes to this:



                            $('#table').editable({
                            container: 'body',
                            selector: 'td.Item',
                            title: 'Item',
                            type: "POST",
                            mode: 'inline',
                            showbuttons: false,
                            source: ITEM,
                            validate: function(value) {
                            if ($.trim(value) == '') {
                            return 'Empty!';
                            }
                            }
                            });


                            Added mode:'inline'






                            share|improve this answer













                            You can either create your own data-type: example.



                            Or another thing you can do, which does not show the list right away, but is less cumbersome: make the select inline. Change the editable for the select datatypes to this:



                            $('#table').editable({
                            container: 'body',
                            selector: 'td.Item',
                            title: 'Item',
                            type: "POST",
                            mode: 'inline',
                            showbuttons: false,
                            source: ITEM,
                            validate: function(value) {
                            if ($.trim(value) == '') {
                            return 'Empty!';
                            }
                            }
                            });


                            Added mode:'inline'







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 16 '18 at 14:53









                            SBylemansSBylemans

                            1,137619




                            1,137619























                                0














                                There's an issue with the select2 version 4, stating we cannot use input tags anymore.




                                1. http://github.com/select2/select2/issues/3057

                                2. https://github.com/vitalets/x-editable/issues/979


                                It is recommended to use a <select> element, documentation for reference.



                                Another link might be helpful for you






                                share|improve this answer




























                                  0














                                  There's an issue with the select2 version 4, stating we cannot use input tags anymore.




                                  1. http://github.com/select2/select2/issues/3057

                                  2. https://github.com/vitalets/x-editable/issues/979


                                  It is recommended to use a <select> element, documentation for reference.



                                  Another link might be helpful for you






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    There's an issue with the select2 version 4, stating we cannot use input tags anymore.




                                    1. http://github.com/select2/select2/issues/3057

                                    2. https://github.com/vitalets/x-editable/issues/979


                                    It is recommended to use a <select> element, documentation for reference.



                                    Another link might be helpful for you






                                    share|improve this answer













                                    There's an issue with the select2 version 4, stating we cannot use input tags anymore.




                                    1. http://github.com/select2/select2/issues/3057

                                    2. https://github.com/vitalets/x-editable/issues/979


                                    It is recommended to use a <select> element, documentation for reference.



                                    Another link might be helpful for you







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Nov 16 '18 at 15:55









                                    scadyyscadyy

                                    357




                                    357























                                        0














                                        There is an issue with select2.min.js in version 4. So , You needd to replace bellow link



                                        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>


                                        with



                                        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>





                                        share|improve this answer
























                                        • Thanks I didnt noticed

                                          – MoteCL
                                          Nov 24 '18 at 12:39
















                                        0














                                        There is an issue with select2.min.js in version 4. So , You needd to replace bellow link



                                        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>


                                        with



                                        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>





                                        share|improve this answer
























                                        • Thanks I didnt noticed

                                          – MoteCL
                                          Nov 24 '18 at 12:39














                                        0












                                        0








                                        0







                                        There is an issue with select2.min.js in version 4. So , You needd to replace bellow link



                                        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>


                                        with



                                        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>





                                        share|improve this answer













                                        There is an issue with select2.min.js in version 4. So , You needd to replace bellow link



                                        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>


                                        with



                                        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.full.js"></script>






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Nov 23 '18 at 10:29









                                        Falguni PrajapatiFalguni Prajapati

                                        1216




                                        1216













                                        • Thanks I didnt noticed

                                          – MoteCL
                                          Nov 24 '18 at 12:39



















                                        • Thanks I didnt noticed

                                          – MoteCL
                                          Nov 24 '18 at 12:39

















                                        Thanks I didnt noticed

                                        – MoteCL
                                        Nov 24 '18 at 12:39





                                        Thanks I didnt noticed

                                        – MoteCL
                                        Nov 24 '18 at 12:39


















                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300364%2fautomatically-displays-the-option%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Xamarin.iOS Cant Deploy on Iphone

                                        Glorious Revolution

                                        Dulmage-Mendelsohn matrix decomposition in Python