设置值:
$("#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>");
}