ligerForm 二级联动

来源:互联网 发布:java库存盘点系统源码 编辑:程序博客网 时间:2024/06/07 02:46
/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */
//@description 默认表单编辑器构造器扩展(如果创建的表单效果不满意 建议重载)//@param {jinput} 表单元素jQuery对象 比如inputselecttextarea $.ligerDefaults.Form.editorBulider = function (jinput){    //这里this就是formligerui对象    var g = this, p = this.options;    var inputOptions = {};    if (p.inputWidth) inputOptions.width = p.inputWidth;    if (p.fields[0].options.onSelected) inputOptions.onSelected  = p.fields[0].options.onSelected;    if (jinput.is("select"))    {        jinput.ligerComboBox(inputOptions);    }    else if (jinput.is(":text") || jinput.is(":password"))    {        var ltype = jinput.attr("ltype");        switch (ltype)        {            case "select":            case "combobox":                jinput.ligerComboBox(inputOptions);                break;            case "spinner":                jinput.ligerSpinner(inputOptions);                break;            case "date":                jinput.ligerDateEditor(inputOptions);                break;            case "float":            case "number":                inputOptions.number = true;                jinput.ligerTextBox(inputOptions);                break;            case "int":            case "digits":                inputOptions.digits = true;            default:                jinput.ligerTextBox(inputOptions);                break;        }    }    else if (jinput.is(":radio"))    {        jinput.ligerRadio(inputOptions);    }    else if (jinput.is(":checkbox"))    {        jinput.ligerCheckBox(inputOptions);    }    else if (jinput.is("textarea"))    {        jinput.addClass("l-textarea");    }}
$("#formsearch").ligerForm({    fields:[        { display:"<s:text name="test1" />",name:"test1",newline:false,labelWidth:90,width:150,space:30,type:"select",cssClass:"field",            attr: { "op": "equal"},            comboboxName:"test1",            options:{                onSelected : function (newvalue)                {                    var data1=[                        { text: 'a', id: '0' },                        { text: 'b', id: '1' },                        { text: 'c', id: '2' }                    ];                    var data2=[                        { text: 'A', id: '0' },                        { text: 'B', id: '1' },                        { text: 'C', id: '2' }                    ];                    var combo = liger.get('test2');                    console.log(liger.get('test1'));                    console.log(liger.get('test2'));                    if (!combo) return;                    if(newvalue==0){                        combo.setData( data1);                    }                    if(newvalue==1){                        combo.setData( data2);                    }                },            valueFieldID:"test1",                data:[                    { text: 'a', id: '0' },                    { text: 'b', id: '1' }                    ]               }        },        { display:"<s:text name="test2" />",name:"test2",newline:false,labelWidth:90,width:150,space:30,type:"select",cssClass:"field",            attr: { "op": "equal"},            comboboxName:"test2",            options:{                onSelected :null,                data: null,                valueFieldID:"test2"            }        }        <%--{display:"<s:text name="i.program.content.code" />",name:"contentCode",newline:false,labelWidth:120,width:120,space:30,type:"text",cssClass:"field"},--%>    ],    toJSON: JSON2.stringify});
 ###################jQuery ligerUI 1.3.3
$.ligerDefaults.Form.editorBulider = function (jinput){    //这里this就是formligerui对象    var g = this, p = this.options;    if (!jinput || !jinput.length) return;    var options = {}, ltype = jinput.attr("ltype"), field =p.fields[0];    if (p.readonly) options.readonly = true;    options = $.extend({        width: (field.width || p.inputWidth) - 2    }, field.options, field.editor, options);    var control = null;

原创粉丝点击