我想获取SharePoint列表的所有项目,但不是默认列数据。
基本上,我希望向用户显示所有可编辑的SharePoint列表项。
我如何使用CAML Query和C#?
答案 0 :(得分:0)
您可以使用此代码段来确定字段是否可编辑:
public static bool IsFieldEditableInSP2010(SPField spField)
{
SPList spList = spField.ParentList;
SPFieldLookup fldLookup = spField as SPFieldLookup;
bool bCountRelated = fldLookup != null && fldLookup.CountRelated;
bool bMcolLookup = fldLookup != null && fldLookup.IsDependentLookup &&
fldLookup.LookupList != "Docs";
SPFieldType t = spField.Type;
if (t == SPFieldType.Computed ||
t == SPFieldType.File ||
t == SPFieldType.Recurrence ||
t == SPFieldType.CrossProjectLink ||
t == SPFieldType.AllDayEvent)
{
return false;
}
if (!spField.Reorderable &&
!bCountRelated &&
!(spField.ReadOnlyField && spField.Type == SPFieldType.User) &&
!(bMcolLookup && !spField.Hidden) &&
!spList.HasExternalDataSource)
{
return false;
}
if ((spField.ReadOnlyField && !bCountRelated && !bMcolLookup) ||
spList.HasExternalDataSource)
{
if(spField.Type == SPFieldType.Calculated || spField.Type == SPFieldType.User)
return true;
}
else
return true;
return false;
}