ligerComboBox下拉列表

来源:互联网 发布:图文直播源码 编辑:程序博客网 时间:2024/06/05 08:05

设置值:

$("#comtype").ligerGetComboBoxManager().setValue(data.SPType);

 

 

加载方法一:

<inputtype="text"id="messagetype"name="messagetype"/>

 

//获取提示类别

function GetMessageTypeDictionary() {

$.post('@Url.Action("GetMessageTypeDictionary","Message")',

function (json) {

$("#messagetype").ligerComboBox({ data: json,lable: '类型', labelWidth: 100, labelAlign: 'right' });                

       },"json"

);

}

  

[HttpPost]

publicstring GetMessageTypeDictionary()

{

string json ="";

JavaScriptSerializer jss =newJavaScriptSerializer();

List<Model.BusDictionary>busdiclist =newList<Model.BusDictionary>();

BLL.BusDictionary bllcity =new BLL.BusDictionary();

string strwhere ="";

strwhere = " BusType='serproduct' ";

busdiclist =bllcity.GetModelList(strwhere);

json=jss.Serialize(busdiclist);

json = json.Replace("BusDicName","text");

json = json.Replace("BusDicNum","id");

 

return json;

}

 

加载方法二:

publicActionResult Index()

{

ViewBag.PSType =GetSPType();

return View();

}

 

//获得类型下拉

publicstring GetSPType()

{

string json ="";

JavaScriptSerializer jss =newJavaScriptSerializer();

BLL.BusDictionary bllbd =new BLL.BusDictionary();

List<Model.BusDictionary>bdlist =newList<Model.BusDictionary>();

string opid = (string)Session["UserGUID"];

BLL.Sys_OperatorArea blloa =new BLL.Sys_OperatorArea();

List<Model.Sys_OperatorArea> oalist =newList<Model.Sys_OperatorArea>();

oalist =blloa.GetModelList(string.Format("GUID='{0}'", opid));

string cityid ="";

if (oalist.Count > 0)

{

foreach (Model.Sys_OperatorArea oain oalist)

{

cityid += string.Format("'{0}',", oa.CityID);

}

cityid =cityid.Substring(0, cityid.Length - 1);

 

bdlist =bllbd.GetModelList(string.Format(" BusType='serproduct' and DELETEFLAG='0' and Area in({0}) ",cityid));

 

var b = bdlist.Select(d =>new

{

text = d.BusDicName,

id = d.BusDicNum

});

json = jss.Serialize(b);

}

return json;

}

 

var strProcedureName ='@Html.Raw(ViewBag.PSType)'

//生成类型下拉

var selectdata = eval(strProcedureName);

for (var i = 0; i < selectdata.length; i++) {

$("#seleSPType").append("<option value='" + selectdata[i].id + "'>" + selectdata[i].text +"</option>");

}