2plus2
|
|
« on: April 01, 2013, 01:13:34 PM » |
|
I'm trying to set the value of a combo box when the row.<field> is null. If I don't trap for null, the combo box value is set to "" by the form load event. e.g.
if ($('#TieredApproval_Yes').is(':checked')) { $('#Tier').combobox({ valueField: 'id', textField: 'text', panelHeight: 'auto', url: '/admin/ajax.aspx?a=getTieredList&r=' + $('input:radio[name=TierLevel]:checked').val() + '&i=' + row.NmbrOfApprovers, onLoadSuccess: function () { $('#fmThresholdDetail').form('load', row); } }); } else { $('#fmThresholdDetail').form('load', row); }
everything loads correctly, except when row.Tier is null because there is no data in the source grid. Then the default selection is not used, and the combo box "value" is set to null/"". So I thought I could check and force the default value:
if ($('#TieredApproval_Yes').is(':checked')) { $('#Tier').combobox({ valueField: 'id', textField: 'text', panelHeight: 'auto', url: '/admin/ajaxOwners.aspx?a=getTieredList&r=' + $('input:radio[name=TierLevel]:checked').val() + '&i=' + row.NmbrOfApprovers, onLoadSuccess: function () { $('#fmThresholdDetail').form('load', row); if (!row.Tier) { $('#Tier').combobox({ 'setValue': '*' }); } } }); } else { $('#fmThresholdDetail').form('load', row); }
The result leaves the comb box drop down not populated, and when I go into debug mode with Crome the above causes the onLoadSuccess to continually fire - some type of infinite loop? So I was guessing that the setValue method is causing some event to fire that is trapped by the onLoadSuccess.
I've routed around it by manually populating the form instead, but was hoping for a more elegant solution.
Thoughts?
|