EasyUI Forum
May 03, 2024, 11:59:20 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: With ComboBox does setValue fire an event?  (Read 14001 times)
2plus2
Jr. Member
**
Posts: 75


View Profile
« 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?
Logged
2plus2
Jr. Member
**
Posts: 75


View Profile
« Reply #1 on: April 01, 2013, 01:25:23 PM »

(Why does the act of typing out a question focus the mind? :-)

Here's the elegant solution:

                   onLoadSuccess: function () {
                       if (!row.Tier) {
                           row.Tier = '*';
                       }
                       $('#fmThresholdDetail').form('load', row);
                   }

Not sure why I thought the row object would be read-only.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!