combobox editor

combobox editor

vacanitovacanito Posts: 9Questions: 2Answers: 0
edited June 2018 in Free community support

Greeting, I am using Inline editing with a submit button to a column to implement a combobox with the system of Joined tables, these records are created empty is to say that only the first data is entered when it is edited. I discovered that when I edit any cell in the registry I automatically edit the combobox by selecting the first name in the list. Any idea how I can control this or how do I make the first item in the combobox list blank? Thanks for the help.

In the staff.php

Field::inst( 'dettagli.idClienti' )
            ->options( Options::inst()
                ->table( 'clienti' )
                ->value( 'idClienti' )
                ->label( 'nome' )
            ),
            ->validator( Validate::dbValues() ),
        Field::inst( 'clienti.nome' ),

In the Javascript

label: "Acquirente:",
                name: "dettagli.idClienti",
                type: "select"
                
            },

{ data: "clienti.nome", editField: "dettagli.idClienti" },

This question has an accepted answers - jump to answer

Answers

  • vacanitovacanito Posts: 9Questions: 2Answers: 0

    somebody help me?

  • vacanitovacanito Posts: 9Questions: 2Answers: 0

    I need at least the first item in the combobox to be blank so that I do not select a valid item from the list, How do I make the first item blank?

  • allanallan Posts: 61,695Questions: 1Answers: 10,102 Site admin

    Could you give me a link to the page showing the issue so I can help debug it please? The select element should take the current value when you trigger editing on the row, and absolutely should not be setting itself to the first item in the list. That suggests to me that the value of the row isn't in the list of options available.

    Thanks,
    Allan

  • vacanitovacanito Posts: 9Questions: 2Answers: 0

    Hello Allan, thank you for responding, I apologize for the fact that I have formulated the question incorrectly, what happens is the following. I have a cell with a select where a list is displayed works perfect. The problem is that when I edit any cell within the row, edit the cell with the select.
    The select is in custom, try to update any cell other than custom and you will see how to update custom automatically. Thanks for the help.

    http://paracabellos.com/dettagli/core/vista/dettagli.php?valor=3890

  • vacanitovacanito Posts: 9Questions: 2Answers: 0

    Any suggestions?

  • allanallan Posts: 61,695Questions: 1Answers: 10,102 Site admin
    Answer ✓

    What's happening is that the following options are being loaded into your select:

            "dettagli.idClienti": [{
                "label": "NAME 1",
                "value": "936"
            }, {
                "label": "NAME 10",
                "value": "4974"
            }, {
                "label": "NAME 11",
                "value": "4975"
            }, {
                "label": "NAME 12",
                "value": "4976"
            }, {
                "label": "NAME 13",
                "value": "4977"
            }, {
                "label": "NAME 14",
                "value": "4978"
            }, {
                "label": "NAME 15",
                "value": "4979"
            }, {
                "label": "NAME 16",
                "value": "4980"
            }, {
                "label": "NAME 17",
                "value": "4981"
            }, {
                "label": "NAME 18",
                "value": "4982"
            }, {
                "label": "NAME 19",
                "value": "4983"
            }, {
                "label": "NAME 2",
                "value": "937"
            }, {
                "label": "NAME 20",
                "value": "4984"
            }, {
                "label": "NAME 3",
                "value": "1055"
            }, {
                "label": "NAME 4",
                "value": "1291"
            }, {
                "label": "NAME 5",
                "value": "1856"
            }, {
                "label": "NAME 6",
                "value": "3458"
            }, {
                "label": "NAME 7",
                "value": "4230"
            }, {
                "label": "NAME 8",
                "value": "4972"
            }, {
                "label": "NAME 9",
                "value": "4973"
            }]
    }
    

    That's fine, but as you will be able to see, none of the options values are an empty string. That means that if the cell is currently empty it can't find an option matching the current value, thus it takes the value of the first option - labeled NAME 1 in this case.

    The way to handle this is to make use of the placeholder options of the select field type:

    placeholder: "Select a name",
    placeholderDisabled: false,
    placeholderValue: ''
    

    That will basically just add an empty string to the options list for your automatically.

    Allan

  • vacanitovacanito Posts: 9Questions: 2Answers: 0

    Thanks Allan, you are a genius :) Working 100%

This discussion has been closed.