Panel dropdown list?

Panel dropdown list?

stpstp Posts: 6Questions: 2Answers: 0

Hey

I have a problem when i use function createPanel.
All Input type (data-editor-field) field works great, but select list not working on Panel?

I use this code editing my own program..
https://editor.datatables.net/examples/standalone/collection.html

Row
'<dd data-editor-field="customer.treatment_id">'+data.customer.treatment_id+'</dd>'+

and
editor = new $.fn.dataTable.Editor( {
ajax: "js_customer.php",
fields: [ {
label: "Treatment:",
name: "customer.treatment_id",
type: "select"
}.......

This same code work if i use normal datatable, not not as use Panel.

Answers

  • stpstp Posts: 6Questions: 2Answers: 0
    edited January 2019

    One more situation.
    If i use, static options it's works.

    options: [
    { label: "Status1", value: "1" },
    { label: "Status0", value: "0" },
    ]

    But my options is relation mysql, not works

    Field::inst( 'customer.treatment_id' )
    ->options( Options::inst()
    ->table( 'customer_treatment' )
    ->value( 'id' )
    ->label( 'treatment' )
    ),

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

    Right - when you are using DataTables, then Editor can automatically listen for the xhr event and check to see if there are any options for its list fields. Since you aren't using DataTables there is no Ajax request that Editor can automatically listen to, so there is no way for it to populate the options.

    Two options:

    1. Make the Ajax request to get the options yourself - then use editor.field('customer.treatment_id').update( ...options... );, or
    2. Set the options statically if they are available.

    Allan

  • stpstp Posts: 6Questions: 2Answers: 0

    Thanks, my knowledge for Ajax and JavaScript is not enough to do this.
    So i find some examples.

This discussion has been closed.