Hot to show dropdown (select-box) in view mode of editor

Hot to show dropdown (select-box) in view mode of editor

ambadambad Posts: 3Questions: 1Answers: 0

Hi,

I have a question regarding this example:
https://editor.datatables.net/examples/inline-editing/join.html

If I click on the location, a dropdown of possible locations is shown.
Is it also possible to show the locations dropdown in view mode already?

I know, that I could use the render-parameter of datatable itself but this does'nt work with the select-type of editor. Or am I wrong in this?

Thanks in advance,
Dirk

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Is it also possible to show the locations dropdown in view mode already?

    As far as I am aware no. There is no API for the select element to make it show from Javascript.

    The only option is to use a Javascript based alternative such as Select2 or Selectize.

    Allan

  • ambadambad Posts: 3Questions: 1Answers: 0

    I'm not sure, if I understand you right. In the given example, we have this configuration of editor for the sites-column

               {
                    label: "Site:",
                    name: "users.site",
                    type: "select"
                }`
    

    The datatable-configuration looks like this:

    { data: "sites.name", editField: "users.site" }

    This shows the site name as a string.

    So if I click on the site name, the dropdown will be shown.

    To change the datatable rendering from a string to a dropdown, I currently would add a render-configuration

                                {data: null,
                                editField: 'users.site',
                                render: function(d,t,r){
                                    var $select = $("<select></select>", ...
    
    

    My guess was, that Editor/Datatable has a configuration which already does it.
    If you are saying, that Select2 could do this, where would you embed that?

    Thanks a lot,
    Dirk

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    I think I might not have understood. Are you looking to have the select element display in its "open" state when you click on a cell to edit it?

    Or are you looking for something more like this - just for select inputs?

    Allan

  • ambadambad Posts: 3Questions: 1Answers: 0

    Or are you looking for something more like this - just for select inputs?

    Yes, this is exactly what I am looking for! Are there any examples available (assuming it is possible to do)?

    Thanks so far,
    Dirk

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    I don't have an example using a select input, but it should just be a case of modifying that example. I don't see any reason why it won't work.

    Allan

This discussion has been closed.