Dependent fields in use with type:"datatable"
Dependent fields in use with type:"datatable"
Hello,
i want to use the function "dependent()" on a field with the option "type: datatable".
Contacts should be updated after selecting a company.
if i select a company the contacts that belongs to that company will be loaded. This works.
Problem 1: But the the previously selected contacts will not be selected again
{
label: "Kontakt:",
name: "CMDB_Ci_Contact_View[].cmdb_asset_id",
type: "datatable",
multiple: true,
config: {},
},
initComplete: function(settings, json) {
//Dependent
editor.dependent('CMDB_Asset.xrm_company_id', 'ajax/cmdb/assets/computer/dependent_updateContactByCompany.php');
as a workaround i tested it without the function "dependent()" and updated the contacts with a search. This works.
But the results will not be ordered by the previously selected contacts..
Problem 2: Maybe someone has an idea how to show the previously selected contacts at the top of the table.
editor.field('CMDB_Asset.xrm_company_id').input().on('change', function() {
var cur_value = $('option:selected', this).text();
var table2 = $('#DataTables_Table_0').DataTable();
table2.search(cur_value).draw()
});
editor.on('open', function() {
var cur_value = editor.field('CMDB_Asset.xrm_company_id').input();
var cur_value = $('option:selected', cur_value).text();
var table2 = $('#DataTables_Table_0').DataTable();
table2.search(cur_value).draw()
});
Replies
That typically would happen if the value being selected isn't in the table (usually a case of the label and value being mixed). Can you give me a link to your page showing the issue?
There isn't an option to have the table sorted based on row selection at this time I'm afraid. It might be possible using a plug-in, but it might prove tricky due to the row caching and the fact that sorting is based on column data. A hidden column that returns the row's selected state would need to be used. I suspect that would get quite confusing when selecting and unselecting rows though.
Allan
Hello Allan,
the application is on my local intranet.
but i have some information, i hope this will help
table.php
dependent.php
Can you show me the
CMDB_Asset.xrm_company_id
configuration please? Could you also use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.Thanks,
Allan
Sorry for my late response,
unfortunately i can not upload the sensitive data
Can you show me a row of the data that is being loaded for the DataTable please (the
data
array in the response JSON)?Thanks,
Allan