Editor display the values in the select
Editor display the values in the select
klermann
Posts: 277Questions: 67Answers: 1
Hello Allan, how do I retrieve, to display the values in the select, coming from the table that comes from the database? Because when trying to recover these values my select is empty!
I'm using the select2 plugin available here!
The list of items is available, but the value is not set!
ec2-54-86-12-163.compute-1.amazonaws.com:8080/financeiro/receitas
This discussion has been closed.
Answers
Hello Allan, how do I retrieve, to display the values in the select, coming from the table that comes from the database? Because when trying to recover these values my select is empty!
I'm using the select2 plugin available here!
The list of items is available, but the value is not set!
ec2-54-86-12-163.compute-1.amazonaws.com:8080/financeiro/receitas
I'm getting a "denied" at that link I'm afraid.
I don't really understand this I'm afraid. The values passed into the
set
plug-in function are the values that should be selected.Allan
http://ec2-54-86-12-163.compute-1.amazonaws.com:8080/financeiro/receitas
it's normal! Check again please!
I understand this, but the values are in lilsta, but does not retrieve the item when I try to edit an item, they are presented in the table, remembering that the values that are retrieved from the list come individually by json in another function!
Yes, it appears to load for me okay now.
I believe the problem you are having is that you are trying to select based on the label not the value.
For example, this is the option in the Select2 list:
If you pass in a value of "Tipo de Receita" it won't select anything since the value is actually 0. The field is set up as
tipoReceitas.nome
, so I'm fairly certain this is the issue. You need to select based on the id (whatever the name of that is).The join documentation and example has full details about this.
Allan
You tell me this is my server returning a json in this format, which is what you went through. The leftJoin () method will bring the item concerned and make a link to the electronic version. The question is where does this method use: leftJoin ().
{
"users": {
"first_name": "Quynn",
"last_name": "Contreras",
"phone": "1-971-977-4681",
"site": "1"
},
"sites": {
"name": "Edinburgh"
}
}
Remember that you use java, and I may very well generate the output!
In my example we have:
The label (which is shown in the DataTable column) is
sites.name
- in this case Edinburgh.The value (which Editor edits) is
users.site
- in this case 1.Note that they are different property names. I don't want the select to edit the label, I want it to edit the selected value.
Allan
Hello Allan, make an implementation that asked me and I did not get the expected result, which seems to take a look please?
ec2-54-86-12-163.compute-1.amazonaws.com:8080/financeiro/receitas/
Hello Allan I followed all your guidance, but not for sure, for me what is difficult is a list that fills the select comes from a different json, and now I presented the field in the table as directed but not presented in the select! What to do?
In the DataTable you are showing:
I'm not sure why it is an array of data, but it appears to be so.
In the Editor you have:
So the first issue is that DataTables is working with an array, while Editor is using an object.
The second issue is that presumably you don't actually want to edit
tipoReceitas.nome
you want to edit something that points to that. What is the column name you want to edit?Allan
I'm trying to first a column like "conta"..
In editor
{
name: 'minhasContas.nome',
"type": "select2",
"ipOpts": lists(),
"opts": {
"placeholder": "Selecione uma conta ...",
"allowClear": true
}
},
and table
{
data: "mContas"
},
I am using the select2 plugin ...
Its the same issue as we've discussed before.
The data source object for the row looks like this:
The Editor configuration is:
And the list of options for the Select2 list is:
The values are numbers. The
minhasContas.nome
property doesn't actually exist (minhasContas
is an array). And even if it did correctly select the name, that would pick Contas1 not the number!The value needs to reflect what you are editing. Not the label.
Allan
I do not quite understand what you mean, what do I actually change? Is the configuration or the JSON file? How should I stay in my file? An example please!
And remembering that to create or edit the data comes from two JSON files, the main one and the one that fills the list
There is an example showing how to do a join here.
I would actually suggest that you remove Select2 and just use a
select
until you get this working.There are two points:
minhasContas.nome
property doesn't actually exist in your data object.Note how in my example the
users.site
field is the one that is edited, butsites.name
is the one that is displayed in the DataTable.Allan