EasyUI Forum
September 13, 2025, 09:02:51 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: combotree setValue Error  (Read 6171 times)
taitai09
Newbie
*
Posts: 1


View Profile Email
« on: June 03, 2020, 11:27:02 PM »

An error occurs when using the function setValue in the combotree.

SetValue was used to select specific information from onLoadSuccess events.
Please check if it's the wrong usage!


- The following error syntax is applicable.

TypeError: Cannot read property 'options' of undefined
    at options (jquery.easyui.min.js:7887)
    at s.fn.init.$.fn.textbox (jquery.easyui.min.js:7856)
    at options (jquery.easyui.min.js:14881)
    at s.fn.init.$.fn.combo (jquery.easyui.min.js:14855)
    at options (jquery.easyui.min.js:15720)
    at s.fn.init.$.fn.combotree (jquery.easyui.min.js:15703)
    at HTMLUListElement.<anonymous> (jquery.easyui.min.js:15746)
    at Function.each (jquery.3.4.1.js:367)
    at s.fn.init.each (jquery.3.4.1.js:202)
    at setValues (jquery.easyui.min.js:15745)

TypeError: Cannot read property 'options' of undefined
    at options (jquery.easyui.all.js:10258)
    at s.fn.init.$.fn.textbox (jquery.easyui.all.js:10220)
    at options (jquery.easyui.all.js:18932)
    at s.fn.init.$.fn.combo (jquery.easyui.all.js:18899)
    at options (jquery.easyui.all.js:20005)
    at s.fn.init.$.fn.combotree (jquery.easyui.all.js:19982)
    at HTMLUListElement.<anonymous> (jquery.easyui.all.js:20043)
    at Function.each (jquery.3.4.1.js:367)
    at s.fn.init.each (jquery.3.4.1.js:202)
    at setValues (jquery.easyui.all.js:20042)


- The following is the relevant code.

$('#wrkjob_cd_top_level').combotree({
      url:workjobComboTreeUrl,
      method:"get",
//      valueField:'id',
//      textField:'text',
      id: 'id',
      text: 'text',
      onLoadError: function(){
         parent.$.messager.alert('','...');
         return false;
      },
      onLoadSuccess: function(node, data){
         if($('#_isHandOff').val() == 'Y') {
            try {
               console.log(data);
               
               for(let dataIndex = 0; dataIndex < data.length; dataIndex++) {
                  let id = data[dataIndex].id;
                  let text = data[dataIndex].text;
                  
                  if($('#_wrkjob_cd').val() == id) {
                     alert("id:" + id + ", text:" + text);
                     $(this).combotree('setValue', {id: id, text: text});
//                     $(this).combotree('setValue', $('#_wrkjob_cd').val());   // It's Error

                  }
               }
               
            } catch(error) {
               console.log(error);
            }
         }
      }
   });
///// End of Code


Addition 1.
but, the onLoadSuccess function calls to another function, and the setValue from there performs normal operation.

I want to know if it works differently from combobox.

- code
function workjobComboTree(isTopLevel) {
   ...   
   $('#wrkjob_cd_top_level').combotree({
      url:workjobComboTreeUrl,
      method:"get",
//      valueField:'id',
//      textField:'text',
      id: 'id',
      text: 'text',
      onLoadError: function(){
         parent.$.messager.alert('','...');
         return false;
      },
      onLoadSuccess: function(node, data){
         combotreeSetValue();
      }
   });
}

function combotreeSetValue() {
   $('#wrkjob_cd_top_level').combotree('setValue', $('#_wrkjob_cd').val());
}


Addition.2
Of the properties of the combotree (valueField, textField) information,
(id, text)Should it be changed to information?
« Last Edit: June 04, 2020, 02:03:44 AM by taitai09 » Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #1 on: June 11, 2020, 12:22:30 AM »

Please try this code instead.
Code:
var ct = $('#wrkjob_cd_top_level');
ct.combotree({
...
onLoadSuccess: function(){
ct.combotree('setValue', $('#_wrkjob_cd').val());
}
});
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!