我有jquery jtable,它有动态选项。它工作正常。如果我从下拉列表中选择0,那么它将不会显示表。当第一次加载表时它工作正常。但是当我更新{ {3}}值0未显示的选项。
如果我有除0之外的任何其他数字,那么它将显示。第三行是一个例子。我从下拉列表中选择0它正确更新数据库但不会显示在桌面上。任何人都知道为什么它是否正在发生。我试图加载表但仍无效。
以下是代码。
$('#cribList').jtable({
sorting: true,
defaultSorting: 'Number ASC',
selecting: true, //Enable selecting
multiselect: true, //Allow multiple selecting
selectingCheckboxes: true, //Show checkboxes on first column
actions: {
listAction: 'Rooms.aspx/LoadRoom?database=<%= Request["database"].ToString() %>',
deleteAction: 'Rooms.aspx/DeleteRoom?database=<%= Request["database"].ToString() %>',
updateAction: 'Rooms.aspx/UpdateRoom?database=<%= Request["database"].ToString() %>',
createAction: 'Rooms.aspx/CreateRoom?database=<%= Request["database"].ToString() %>'
},
TypeID: {
title: 'Type',
width: '30%',
inputClass: 'validate[required]',
options: <%= DisplayRoomOptions() %>
},
Stacks:{
title: 'Stacks',
width: '30%',
dependsOn:'TypeID',
listClass: 'centerCol',
options: function (data)
{
if (data.source == 'list')
{
return <%=appdomain%> +'/Rooms.aspx/GetRoomOptions?TypeID=0';
}
return <%=appdomain%> +'/Rooms.aspx/GetRoomOptions?TypeID='+data.dependedValues.TypeID;
}
Code behind
[WebMethod(EnableSession = true)]
public static object GetRoomOptions(int TypeID)
{
try
{
int[] configRooms = new int[6]; ;
if (TypeID == 2)
configRooms = new int[] { 0, 1, 2, 3 };
else if ((TypeID == 3) || (TypeID == 4))
configRooms = new int[] { 0, 1, 2, 3, 4, 5 };
else if (TypeID == 1)
configRooms = new int[] { 0 };
else
configRooms = new int[] { 0, 1, 2, 3, 4, 5 };
return new { Result = "OK", Options = configRooms };
}
catch (Exception ex)
{
return new { Result = "ERROR", Message = ex.Message };
}
}
更新代码
[WebMethod(EnableSession = true)]
public static object UpdateRoom(GuardRoomData.Room.record)
{
try
{
record.Save(HttpContext.Current.User.Identity.Name);
return new { Result = "OK" };
}
catch (Exception ex)
{
GuardRoomData.Log.WriteError("Save Room (user '" + HttpContext.Current.User.Identity.Name + "'): " + ex.ToString());
return new { Result = "ERROR", Message = "Save Room failed: " + ex.Message };
}
}