select幫助類,批量繫結slect

2022-05-30 01:45:09 字數 2586 閱讀 8503

這邊只寫了前端的繫結,後端繫結放在c#部分。

select繫結html

<

select

name

="orderstatusid"

id="orderstatusid"

selectjson

bindjson

>

select

>

呼叫select幫助類js

//

獲取需要繫結物件集合

configdata =;

//在封閉的空間,傳到全域性變數

window.datasourcelist =commonformhelper.getselectdatasource(configdata);

//繫結select物件

commonformhelper.setselecthtmlbydatasourcelist(datasourcelist);

select繫結js:commonformhelper

var commonformhelper =,

init:

function

(settings) , commonformhelper.settings, settings);

if(commonformhelper.settings) ;

};},

load:

function

() ,

getselectdatasource:

function

(settings) }]

settings.async = false

; settings.data =;

var selectjsondata =commonformhelper.getformselectfulljsondatabyname(settings.formid);

var entitylist =;

settings.success = function

(data) ;

};};

};//通過ajax同步方法獲取對應select引數的資料物件集合

ajaxhelper.commonajax(settings);

return

selectjsondata;

},getformselectjsondatabyname:

function

(formid) }}]

var data =;

var formjq = $("#" +formid);

if (formjq.length > 0)

});};

return

data;

},getformselectfulljsondatabyname:

function

(formid) ,bindsource:{}]

var data =;

var formjq = $("#" +formid);

if (formjq.length > 0) );

};});

};return

data;

},setselecthtmlbydatasourcelist:

function

(datasourcelist) }]

if (datasourcelist == null || datasourcelist.length == 0) return

;

for (var i = 0, len = datasourcelist.length; i < len; i++) ;

},setselecthtmlbydatasource:

function

(datasource) }

if (datasource == null || !datasource.name || datasource.datasource == null) return

;

var selectjq = $("[name='" + datasource.name + "']");

if (datasource.bindsource ==undefined) ;

};var html = "";

var bindsource = ;

datasource.bindsource =$.extend({}, bindsource, datasource.bindsource);

if(datasource.bindsource.isall)

for (var i = 0, len = datasource.datasource.length; i < len; i++) ;

selectjq.empty().html(html);

selectjq.data("datasource", datasource);

},setformvaluebyname:

function

(formid, datasource) ;

};thisjq.val(value);}};

});}

};

C 公共幫助類 Image幫助類

大家知道,開發專案除了資料訪問層很重要外,就是common了,這裡就提供了強大且實用的工具。c 公共幫助類 convert幫助類 image類 using system using system.collections.generic using system.text using system.i...

檔案幫助類

public class filehelper else console.writeline request header console.writeline ctx.request.headers.tostring 設定返回內容的mime型別 content disposition attachm...

日誌幫助類

從網上找了些資源,借鑑整理之後,自己隨便寫了乙個。public class loghelper loghelper private static loghelper loghelper private static readonly object sysroot new object 日誌類的單一實...