Hi Abu
I noted that if you use the inline edit and you have some fields with dropdown lists (from database) the dropdown list doesn't show the choise active but seems behave how was an add action, with the dropdown list without any selection.
However the tooltip of the dropdown shows the choise active.
Then I used the below script:
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){setVatDefault();},200); }";
function setVatDefault() {
var vatDefault = $("td[aria-describedby='list2_IDCodiceVat']").attr('title');
if (vatDefault == "undefined") {
var rowid = $('#list1').getGridParam('selrow');
var ifVat = $("#list1").jqGrid("getCell", rowid, "ID4");
if (ifVat != 0)
vatDefault = $("#list1").jqGrid("getCell", rowid, "VatDefault");
else
vatDefault = '';
}
$('#list2 select[name="IDCodiceVat"] option').filter(function() {
return $(this).text() == vatDefault;
}).prop('selected', true);
}
Can you suggest me a better way?
Thanks in advance
Massimo Gagliardi
It should work and show database value preset in dropdown in case of inline edit.
You can review demos/appear/dropdown.php
Most probable issue could be that … you database get_dropdown_value() function should have 'field1 as k' value exactly to what is selected in select_command query.
See 'client_id' used both in dropdown function 'client_id as k' and also in query.
$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients");
$g->select_command = "SELECT id, invdate, invheader.client_id, amount, note FROM invheader
INNER JOIN clients on clients.client_id = invheader.client_id
";