EasyUI Forum
May 16, 2024, 09:43:13 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: reload combobox when it's depend field change in an common way  (Read 6858 times)
yulei
Newbie
*
Posts: 9


View Profile Email
« on: April 20, 2015, 09:04:52 PM »

I add dependForm and dependFields attributes  to field collegeCode.
Code:
<form id="courseListForm" method="post">
<input class="easyui-combobox" id="collegeCode"  name="collegeCode"  style="width:250px"
multiple="multiple"  valueField="code" textField="shortName"
url='${appPath}/college/collegeListData.do'/>

<input class="easyui-combobox" id="collegeCode"  name="collegeCode"  style="width:250px"
multiple="multiple" dependForm="courseListForm" dependFields="termCode" valueField="code" textField="shortName"
url='${appPath}/college/collegeListData.do'/>
other fields...
</form>
after parser onComplete , I call the Component's extParse method if exits
Code:
$.parser.onComplete= function(context){
for(var i=0; i<$.parser.plugins.length; i++){
var name = $.parser.plugins[i];
var r = $('.easyui-' + name, context);
if (r.length){
if (r[name]&&r[name].methods.extParse){
r[name]('extParse');

}
}
}
then i extend an method to combobox
Code:
$.extend($.fn.combobox.methods, {
extParse: function(jq){
jq.each(function(){
var _this = $(this);
//default value
var defaultExtOptions = {
dependForm:null,
dependFields:null,
};
        //markup value
var markupOptions = {
dependForm:_this.attr('dependForm'),
dependFields:_this.attr('dependFields'),
};

//megre extOptions
        var extOptions = $.extend(defaultExtOptions,markupOptions);
       
        if(extOptions.dependFields){
        //register event
        var  dependFields = extOptions.dependFields.split(',');
        for(var i in dependFields){
        //**************************************************
        $('#'+dependFields[i]).textbox('options').onChange=function(){
        _this.combobox('reload');
        };
        }
        }
       
        if(extOptions.dependForm){
        _this.combobox({
        onBeforeLoad: function(param){
        var formData = $("#"+extOptions.dependForm).formToObject();
        $.extend(param,formData);
        }
        });
        }
});
    }
});

the line below many '*****',have errors,so the question is :
combobox extends combo
combo extends textbox.
can i call the parent's 'options' method to get the current options ?
because i can't know ,what the depended component type is
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!