1、datagrid中JS函數(shù)傳值問題:
columns:
{
field: 'TypeName', title: '分類名稱', width: 120, sortable: true,
formatter: function (value, row, index) {
var contentDetails = "<a href='' style='text-decoration: none;' onclick='showDetailsDialog(" + row.ID + ");return false'>" + value + "</a>";
return contentDetails;
}
},
注意,以上點(diǎn)擊事件的傳值( row.ID或者value)一般都是一個(gè)int類型,如果是所傳的值是字符串,則需要注意加轉(zhuǎn)移字符符號(hào)。例如傳值為分類名稱則應(yīng)該如下代碼:
{
field: 'TypeName', title: '分類名稱', width: 120, sortable: true,
formatter: function (value, row, index) {
var contentDetails = "<a href='' style='text-decoration: none;' onclick='showDetailsDialog(\"" + value + "\");return false'>" + value + "</a>";
return contentDetails;
}
},
2、MVC @Html.DropDownList顯示默認(rèn)值問題
視圖頁面代碼:
@Html.DropDownList("ClassPre", (SelectList)ViewBag.JY_Atype_ClassPre, "==請(qǐng)選擇上一級(jí)分類==", new { @style = "width: 60%; height: 32px" })或
@Html.DropDownList("ClassPre", (SelectList)ViewBag.JY_Atype_ClassPre, new { @style = "width: 60%; height: 32px" })
樣式也可以去掉
Controller里面的代碼:
ViewBag.JY_Atype_ClassPre = new SelectList(newList, "ID", "TypeName", model.ClassPre);