Editor not showing current value in select list
Editor not showing current value in select list
Hi,
I am banging my head... I got a few selects i like to show via editor. The general setup is:
1.) as part of the editor setup:
{
"label": "Type",
"name": "type",
"type": "select",
"ipOpts": participantTypesLoader()
},
and in datatable:
"aoColumns": [
{ "mDataProp": "type", "fnRender": function (oObj) {
return getPartname(oObj);
}},
2.) the loader:
function participantTypesLoader () {
partTypes.splice (0,1);
$.ajax ({
url: "${createLink(action: 'listParticipantTypes', controller: 'userContacts')}",
async: false,
dataType: 'json',
success: function (json) {
var len = json.aaData.length;
for (var i=0; i
I am banging my head... I got a few selects i like to show via editor. The general setup is:
1.) as part of the editor setup:
{
"label": "Type",
"name": "type",
"type": "select",
"ipOpts": participantTypesLoader()
},
and in datatable:
"aoColumns": [
{ "mDataProp": "type", "fnRender": function (oObj) {
return getPartname(oObj);
}},
2.) the loader:
function participantTypesLoader () {
partTypes.splice (0,1);
$.ajax ({
url: "${createLink(action: 'listParticipantTypes', controller: 'userContacts')}",
async: false,
dataType: 'json',
success: function (json) {
var len = json.aaData.length;
for (var i=0; i
This discussion has been closed.
Replies
If you `console.log( partTypes );` at the end of the `participantTypesLoader` function - what does it contain? By guess is that the `value` property doesn't exactly match the value that is being edited in the row. If you are able to give us a link to a test case, I'd be able to confirm that.
Regards,
Allan
Testsystem currently only on my system locally.
I have checked this many many times ...
Part of the partTypes array is:
11: Object
label: "Producer"
value: "600"
__proto__: Object
12: Object
label: "Producer"
value: "610"
__proto__: Object
13: Object
label: "Co-Producer"
value: "620"
__proto__: Object
Now, the row to be edited has the following details:
1: {DT_RowId:10, id:10_13, type:610, nickname:Cornelius, salutation:1, title:3, firstname:Cornelius,…}
DT_RowId: 10
city: "München"
company: "MUSICJUSTMUSIC"
country: 81
email: "xxxx"
firstname: "Cornelius"
function: "CEO"
id: "10_13"
lastname: "Kreusch"
middlename: "Claudio"
nickname: "Cornelius"
phone: "xxxxx
salutation: 1
state: null
street: "Occamstrasse 14"
title: 3
type: "610"
web: "http://www.test.de"
zip: "85019"
So the "type" parameter should match with partTypes[12], right?
I am having the same issue with other select entries which are indexed by an integer (not working too) - but i remember that you proposed to use strings in a different forum post for a related topic if i recall correctly.
Any other idea?
thanks a lot ....
Juergen
PS: I could get the test system on a public server during the weekend. But i would prefer to have this solved before.
I might have one more hint to target the problem which seems to be a bug in the editor code:
The datatable does not show all the details - would be way to much. I display just the "salutation" and a "function type" in the table but not the "country" and the persons "title".
Now in the editor the items which are not shown in the datatable are displayed correctly and the ones which are listed in the datatable are not shown.
This would hint that there is a bug in the editor...
Juergen
Thanks for the information.
In the object information, the object has:
> type:610,
but the breakdown below it is:
> type: "610"
These two are not the same. Editor uses strict type checking, so if the array of information for the select list has:
> value: "610"
then what is set in the field must also be a string. Is this the case (its ambitious from the above since it looks like both values are there).
Beyond that, I'm afraid I would need a way to reproduce the error (if its a bug in Editor or otherwise) so I can fix the problem.
Thanks,
Allan
Thanks for the effort ... i think that the objects are available as String and thus are comparable ...
(But i have seen strange comparison behavior in JS many times..)
I try to get you an online access over the weekend.....
cheers
Juergen
Yes please, that would be great. You can PM me access details if you like, by clicking my user name and selecting the "Send Message" option.
Allan
I wrote you an PM...
cheers
Juergen
Thanks for the link - very helpful!
Let's take a specific example from your page - the salutation.
This is how the Editor field is configured:
[code]
{
"label": 'Salutation',
"name": "salutation",
"type": "select",
"default": 3,
"ipOpts": salutationLoader()
},
[/code]
This is what the data from salulationLoader() looks like:
[code]
[
{
"label": "--",
"value": 1
},
{
"label": "Mr.",
"value": 2
},
{
"label": "Ms.",
"value": 3
},
{
"label": "Mrs.",
"value": 4
}
]
[/code]
This is the data for `salutation` from the DataTable:
[code]
salutation: "Mr."
[/code]
So `salutation` is the string "Mr.", not the value 2 - which it would need to be based on the data set.
That's the discrepancy and why it is not working.
What is fix is, well - that's up to yourself :-). You might want to include the salutation ID in the data object for the table (probably what I would do) or you could just build the select data with string values matching the display labels.
Regards,
Allan