ligerComboBox下拉列表

設置值:

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

 

 

加載方法一:

<input type="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]

public string GetMessageTypeDictionary()

{

string json = "";

JavaScriptSerializer jss = new JavaScriptSerializer();

List<Model.BusDictionary>busdiclist = new List<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;

}

 

加載方法二:

public ActionResult Index()

{

ViewBag.PSType =GetSPType();

return View();

}

 

//獲得類型 下拉

public string GetSPType()

{

string json = "";

JavaScriptSerializer jss = new JavaScriptSerializer();

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

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

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

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

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

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

string cityid = "";

if (oalist.Count > 0)

{

foreach (Model.Sys_OperatorArea oa in 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>");

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章