-
Notifications
You must be signed in to change notification settings - Fork 2
Modifying list view
misonou edited this page Sep 14, 2016
·
1 revision
You can specify which columns are visible and their orders on list views (e.g. AllItems.aspx).
[SPContentType("0x01005A132C01F46341319BBA6C776A2D9D32", "My Content Type")]
[SPList]
public abstract class MyItem : SPModel {
// place the title column in front of any other column unspecified
[SPBuiltInField(SPBuiltInFieldName.Title, ColumnOrder = -1)]
public abstract string Title { get; set; }
// place the modified time column at position 2
[SPBuiltInField(SPBuiltInFieldName.Modified, ShowInListView = SPOption.True, ColumnOrder = 2)]
public abstract DateTime Modified { get; set; }
// do not show the modified by column
[SPBuiltInField(SPBuiltInFieldName.Author, ShowInListView = SPOption.False)]
public abstract SPPrincipal ModifiedBy { get; set; }
}
Sometimes it would be a bit tricky if you want to show columns on list views
but it does not refer to any properties in the model class. In that case use SPFieldAttribute.IncludeInViewFields
and
SPFieldAttribute.IncludeInQuery
.
public abstract class MyItem : SPModel {
// tell the library that the "UI Version" column is visible on list view
// but it has nothing to do with the "Title" property it is annotating
[SPBuiltInField(SPBuiltInFieldName._UIVersionString,
ShowInListView = SPOption.True, IncludeInViewFields = false, IncludeInQuery = false)]
[SPBuiltInField(SPBuiltInFieldName.Title, ColumnOrder = -1)]
public abstract string Title { get; set; }
}
-
Working with list items
-
Advanced model class usage
-
Other features