Populating Default in Field Options - Select, Editor
Populating Default in Field Options - Select, Editor
How do I populate a Select dropdown with a Default option when I use "Edit"?
I don't expect "New" to have a default, but when I choose a row value on the table and
click edit, the Select dropdown doesn't pick it up - while the others get their proper values from the table.
I don't expect "New" to have a default, but when I choose a row value on the table and
click edit, the Select dropdown doesn't pick it up - while the others get their proper values from the table.
This discussion has been closed.
Replies
Allan
I'm also not quite sure how to structure our array for JSON to fit what DataTables expects. At the moment the structure is in a for loop and compiling this into the output:
$aaData[] = [
"Server" => $return[$i][Server], "Partner" => $return[$i][Partner], "Tag" => $return[$i][Tag], "Value" => $return[$i][Value]
];
Output:
[[{"Server":{"0":"-ALL-"},"Partner":{"0":"-ALL-"},"Tag":{"0":"IPAddress"},"Value":{"0":"jaworskiodev"}}
I have a feeling fixing the array structure will fix the Select dropdown output as well.
Regards,
Allan
Uncaught TypeError: Cannot read property 'type' of undefined
The full code for the editor is here:
[code]
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "index.php?getJSONAppConfigItems&code=<?php echo $this->items->UID[0]->Value ?>",
"domTable": "#configitems",
"events": {
"onCreate": function (json, data) {
},
"onEdit": function (json, data) {
$.ajax({
type:"POST",
cache:false,
url:"index.php?editJSONAppConfigItems",
data: { dataReturn: data, appUID: "<?php echo $this->items->UID[0]->Value ?>"},
success: function (html)
{
tableInstance.fnReloadAjax();
}
});
}
},
"fields": [ {
"label": "Partner:",
"name": "Partner",
"type": "select",
"ipOpts": [
<?php
foreach ($this->clientObjects->xpath('//*[local-name() = "row"]') as $object)
{
echo '{ "label": "'. $object['Name'].'", "value": "'. $object['UID'].'" },';
}
?>
{ "label": "-ALL-", "value": "00000000-0000-0000-0000-000000000000" }
]
}, {
"label": "Server:",
"name": "Server",
"type": "select",
"ipOpts": [
<?php
foreach ($this->serverObjects->xpath('//*[local-name() = "row"]') as $object)
{
echo '{"label": "'. $object['Name'].'", "value": "'. $object['UID'].'" },';
}
?>
{ "label": "-ALL-", "value": "00000000-0000-0000-0000-000000000000" }
]
}, {
"label": "Tag:",
"name": "Tag"
}, {
"label": "Value:",
"name": "Value",
}
]
} );
[/code]
EDIT: Okay, using sDefaultContent didn't help either... ugh!!! I really need that Select field to work when "new" is pressed.
, {
"type": "radio",
"label": "Days:",
"name": "days",
"ipOpts": [
{ "label": "All", "value": "all" },
{ "label": "Selected:", "value": "selected" }
],
"default": "all"
}