我正在尝试在JQGrid中禁用一行。通过使用HtmlHelper类,JQGrid完成了动态加载。下面给出一个例子,如图所示
public class OBRAccountViewModel
{
[JQGridColumn(IsHidden = true)]
public virtual long OBRBankSeq { get; set; }
[JQGridColumn(IsHidden = true)]
public virtual long OBRSeq { get; set; }
[JQGridColumn(Name = "Overseas Account No", Index = "{0}", Width = 145, IsSearch = true)]
public virtual string OverSeasAccountNo { get; set; }
[JQGridColumn(Name = Constants.DisplayName.BeneficiaryBank, Index = "{0}", Width = 130, IsSearch = true)]
public virtual string BeneficiaryBank { get; set; }
[JQGridColumn(Name = Constants.DisplayName.CurrencyCode, Index = "{0}", Width = 130, IsSearch = true)]
public virtual string CurrencyCode { get; set; }
[JQGridColumn(Name = Constants.DisplayName.AccountClosureDate, Index = "{0}", Width = 130, IsSearch = true,IsEditable=true)]
public virtual DateTime? ClosureDate { get; set; }
[JQGridColumn(Name = Constants.DisplayName.AccountClosureRemarks, Index = "{0}", Width = 250, IsSearch = true, IsEditable = true)]
public virtual string ClosureRemarks { get; set; }
[JQGridColumn(Name = "IsClosed", Index = "{0}", Width = 250, IsSearch = true, IsEditable = true,IsHidden=false)]
public virtual string IsClosed { get; set; }
}
我的视图模型包含七列,其中第7列名称为“IsClosed”。如果此列包含“是”或任何值,则整行应不可编辑。我不知道怎么做。所以有人帮帮我。
我的视图模型如下,
self.map.delegate = self
答案 0 :(得分:1)
如果rowattr
包含"ui-state-disabled ui-jqgrid-disablePointerEvents"
,我建议您使用IsClosed
添加课程"Yes"
。请参阅the old answer我描述的方法。不要忘记使用gridview: true
选项来获得额外的性能优势。
gridview: true,
rowattr: function (rd) {
if (rd.IsClosed === "Yes") { // verify that the testing is correct in your case
return {"class": "ui-state-disabled ui-jqgrid-disablePointerEvents"};
}
}
如果您使用最新版本的free jqGrid,则ui.jqgrid.css
包含CSS规则
.ui-jqgrid-disablePointerEvents {
pointer-events: none;
}
如果您在较旧版本的jqGrid上使用其他分叉,则应手动添加上述角色。
顺便说一句,您可以使用class=""scroll"" cellpadding=""0"" cellspacing=""0""
和class=""scroll"" style=""text-align:center;""
从代码中删除部分。多年以来,该设置已弃用。 jqGrid不要在内部使用类scroll
,只要它存在就删除它。