Creating shell applications in Sitecore’s SheerUI is rather complex. But once you get the hang of it (= have modified enough existing sample code to get a working application) you can do amazing stuff.
Yesterday I had to dynamically alter the columns of my SheerUI listview, and here is what I did.
In the XML file I created my listview:
<Listview ID="IndexList" MultiSelect="false" View="Details" Width="100%" Background="white"> <listviewheader id="IndexHeader"> </listviewheader> </listview>
The header is defined but empty, as I will create them myself.
In the .CS file I added both the InexList and the IndexHeader as private variables:
private Listview IndexList = null; private ListviewHeader IndexHeader = null;
Then in the code where I fill the listview I started with creating my header sections by calling this function:
private void CreateHeader(string name) { ListviewHeaderItem headerItem = new ListviewHeaderItem(); Context.ClientPage.AddControl(IndexHeader, headerItem); headerItem.ID = Control.GetUniqueID("HI"); headerItem.Value = name; headerItem.Name = name; headerItem.Header = name; }
The function will create a new header item, add it to the header and set the header properties to the value contained in the “name” parameter.
When filling in values in the IndexList I have to refer to the header by the header property:
ListviewItem listItem = new ListviewItem(); Context.ClientPage.AddControl(IndexList, listItem); listItem.ID = Control.GetUniqueID("I"); listItem.ColumnValues["somecolumnname"] = somevalue;