SharePoint的列表进行2级以上的分组的方法Word下载.docx
《SharePoint的列表进行2级以上的分组的方法Word下载.docx》由会员分享,可在线阅读,更多相关《SharePoint的列表进行2级以上的分组的方法Word下载.docx(12页珍藏版)》请在冰豆网上搜索。
∙Putthecountsandtotalsatthebottomofeachsection.
∙Dotheabovewithnocustomwebparts,customXSLToranythingthathastobedeployedtotheserver.
Sample:
SecretsandTricksneeded:
∙Itcan'
tbedone"
outofthebox"
inthebrowser
∙SharePointDesignerisneededtomaketheedits
∙YouneedtoconverttheviewwebparttoaSharePointDesignerDataFormWebPart
∙YouneedaSortandGroupsecret
∙Youneedtofixthefooterrows
∙Youneedtomanuallyaddyourtotals,averages,countsetc.
Warning!
SharePoint2010doesnotconsiderapagewithaDataFromWebParttobea“view”.Itonlybelievesthatapageisa“view”whenithasan“XsltListViewWebPart”.In2007wecouldcreateanewview,edititinSharePointDesignerasmuchaswewanted,anditwasstillaview.In2010,SharePointwillnotrecognizeapagewithoutaXsltListViewWebPartasaview.
Sobeforeyoustart…
∙Ifyoujustneedapagewithyourlistnicelygrouped,itmaybebestjusttocreateawebpartpageandstoreitinalibrary.ThenaddtheDataFormWebPartusingthestepsbelow.
∙Ifyouwantthepagetobetreatedasaview,leavetheXsltListViewWebPartonthepage,butmakeithidden.ThenaddtheDataFormWebPartbelowtheexistingwebusingthestepsbelow.
oInSP2010,aviewpagewithanaddedwebpartintroducesabugortwo.Theribbonwillnotbedisplayed.Theviewdropdowninthepagetitleareawillbemissingthedropdowntoselectanotherview.
MyExample:
∙Ihaveasimplelist(actuallyimportedfromExcel)withthesecolumns:
ID1,Bike,BikeType,BikeSize,BikeColorandRetail(price).
∙IwanttogroupthisonBikeType,BikeSize,BikeColorandcounttheitemsandsumoraveragethepriceineachgroup.
CreateanewStandardViewfromthelist'
sviewmenu.
Don'
tbotherwithanyoptionsaswearejustgoingtodeletethedefaultlistwebpart.
Orjustcreateanemptywebpartpage.(see“Warning”above)
The“before”–justastandardviewwithselectedcolumns:
Ifusinganexistingviewpage:
∙OpenyoursitewithSharePointDesignerandclicktheListsandLibrariesnodeintheSiteObjectspane
∙Clickyourlist(“Bikes”inmyexample)
∙Clickyourviewyoucreatedearlier(“Grouped”inmyexample)
Otherwisecreateanewwebpartpageinalibrary
∙Notes(backgroundonly,youcanskipthis):
oTheviewisnowbeingdisplayedusingaXsltListViewWebPart(ItwasaListViewWebPartinSP2007)andcanonlybecustomizedwiththesameoptionsasfoundusingabrowser("
ModifyView"
)
oTheXsltListViewWebParthasthesamegroupinglimitationsandtheListViewWebPart(2levelsofgrouping)
oFormoreinfoonwhathaschangedfromthe2007ListViewWebPartandtheXsltListViewWebPartseeand
oSharePointDesigner2010hastwowebpartsforlists:
▪XsltListViewWebPart-thisisthewebpartusedwhenyoucreateanewView
▪DataFormWebPart–createdfromSharePointDesignerusingInsert,EmptyDataView
oSPD2010addsabitofconfusionwhentryingtoadda“DataView”
▪WhenyouclickInsert,(pickanexistinglist)SPDinsertsanXsltListViewWebPart
▪WhenyouclickInsert,EmptyDataViewSPDinsertsaDataFormWebPart
∙Ifstartingwithanexistingview,deleteorhidetheexistingwebpart.
oDelete:
IntheDesignwindowclickinthewebpart,clicktheWebPartPages:
XsltListViewWebParttab,presstheDeletekey
or
intheCodewindowselecttheentire<
WebPartPages:
XsltListViewWebParttag(includingthestartandendtags)anddeletethecode
oHide:
IntheDesignwindowclickinthewebpart.IntheRibbonintheListViewToolssectionclicktheWebParttabandthenclickProperties.IntheLayoutssectionofpropertiesclickHidden
∙InsertanEmptyDataViewWebpart
oClicktheInsertRibbontabandclicktheDataViewbutton
oClickEmptyDataView
oInthenewwebpartclick“Clickheretoselectadatasource”
oClickyourlistandclickOK(thiswillopentheDataSourceDetailsPane)
oSelectthecolumnsyouwantinyourlist(clickafield,thenShift-clickeachadditionalfield)
oClickthe“InsertSelectedFieldsas”buttonandclick“MultipleItemView”
Note:
IfyoufollowedtheearlierarticleforSharePoint2007,therestofthestepsareprettymuchthesame.
theviewisnowbeingdisplayedusingaDataFormWebPartand:
∙isnolongera“View”andcannotlongerbemodifiedfromthebrowser
∙canbecustomizedfromSharePointDesigner,
∙fromthebrowseryoucanonlyrenametheview,
∙fromthebrowseryoucanalsouseSiteActions,EditPage,ModifySharedWebParttohandedittheXSLT,;
-)
∙goingforward,columnsaddedtothelistwillnotbeautomaticallyaddedtotheDataFormWebPart.YouwillneedtouseSharePointDesignertomanuallyaddthecolumnstothe“view’.
Save!
AtthispointyoumaywanttoclickSaveandreviewtheresultssofarinabrowser.Reviewtheformattingandnotethethingsyouneedtochange.
∙EdittheDataViewWebPart
∙ClickthewebpartandnotethatyounowhaveDataViewToolssectionintheSharePointDesignerribbon.
∙Click“SortandGroup”
∙RemoveanysortfieldsthatmayalreadybeintheSortOrdercolumn
Addyourtopmostgroup:
oClickthefield(BikeType)and
oClickAdd
oClick“Showgroupheader”
oClick“Collapsegroupbydefault”(optional)
oClick“Showgroupfooter”(ifyouwantcountsandtotals)
Addyoursecondgroupbyclickingthefield(Example:
Size)andclickingAdd.
∙Ifyoustophereyouwillhavegroups,butallofyourcountsandtotalswillbewrong!
Weneedtocreateboththetexttodisplayforthegroupandahierarchyforthegrouping.Atthesecondlevelofourgroupingweneedtogrouponthecombinationofbothcolumns,“BikeType”plus“Size”
∙Click“EditSortExpression”
oAtaminimumyouwillneedtoconcatenatethecurrentgroupingcolumnwiththepreviousgroupingcolumns,andwhileyouareatityoucanaddsome“pretty”formatting:
oEnter:
concat(@Bike_x0020_Type,"
-"
@Size)(Watchthecapitalization!
UsetheexactnametheIntelisenseoffers–spacesare“coded”so“BikeType”is“Bike_x0020_Type”.)
oNotethepreviewatthebottomofthedialogbox…
oClickOK
oClickShowgroupheader
oClickCollapsegroup(optional)
oClickShowgroupfooter(ifyouwantcountsandtotals)
∙
Forthethirdandfollowinggroups-repeatthestepabovewithSortExpressionssimilarto:
∙concat(@Bike_x0020_Type,"
@Size,"
@Bike_x0020_Color)
∙Morecolumns?
Ineachnewgroupincludeallofthefieldsfromthepreviousgroupsalongwithanyseparatorsyoulike:
concat(@group1field,@group2field,@group3field,@group4field,@group5field,etc)
orconcat(@group1field,"
@group2field,"
@group3field,"
@group4field,"
@group5field,etc)
∙Ifyoucouldseethefullwidthoftheseyouwouldsee:
BeforeclickingOKtoleavethisdialogbox,checktheorderofthegroups.Theyhaveprobablygottenchanged.(bug?
∙Makesuretheyareinordersomethinglike:
@BikeType
concat(@Bike_x0020_Type,"
@Size)
∙Recheckeachofthesortlevelstoseeifthesearestillchecked:
Optionallyaddonemorecolumnjusttosortthedatawithinthelastgroup.Donotturnonthegroupheaderorgroupfooteroptionsforthissort-onlyfield.
ClickOKtoclosetheSortandGroupdialogbox.
YouwillprobablywanttochangethePagingoptionsastheydefaultto10items.ClickthePagingbuttonintheRibbon(DataViewToolsgroup,Optiontab)
Tip:
IfyouhavealotofdatainthelistSharePointDesignercangetreallyslow.Therearetwothingsyoucoulddohere,setpagingtoasmallnumber(notsogoodfortestingmulti-levelgrouping)orfromtheCommonControlTasksselectShowWithSampleData.
IfyouwantgrandtotalsyouwillalsoneedtoclickDataViewPropertiesandcheckShowViewFooter.
Save!
AtthispointyoumaywanttoclickSaveandreviewtheresultssofarinabrowser.Youshouldnowhaveallofyourgroups.
Clickthe+toexpandasection.
Nowisagoodtimetocleanuptheformattingsuchasthegraybackgroundandoddrowheightinthegroupheaderandfooterrows.(Right-clickintherowinDesignviewandselectCellProperties.
(clickforbiggerview)
Yourgroupingworkisnowdone.Thefollowingstepsareonlyneededifyouwanttoaddtotals,counts,averages,etc.
Nowfortotals!
∙Thesestepsdescribeaddingtotalstothefooterrows,butalsoapplytomodifyingheader(topofeachgroup)rows.
∙TheDataViewsetsuptheheaderandfooterrowsasasinglecellwithacolumnspanof99!
Todisplaytotalsinthesamecolumnsandthedatayouwillneedtofixtheserows.
∙Youwillneedtofixeachofthegroupfooterrowsplustheviewfooterrow.
Inthe