How to make navigation web parts display a custom field

HelenaG Grulichova asked on May 9, 2012 07:53

How to make navigation web parts display a custom field

Correct Answer

HelenaG Grulichova answered on May 9, 2012 07:53

The Site map web part, as well as other navigation web parts, display the DocumentMenuCaption field. If it is empty, the DocumentName is displayed instead. If you need to let users define the caption on the Form tab, you can simply add a new system attribute to the document type in question which would represent the DocumentMenuCaption. This way, all navigation web parts would display the value of the custom system field.

There might be times when you want one navigation web part to display a different field from other navigation web parts. Let's say that you have created a document type field SiteMapTitle that you want to display using the Site map web part, while other navigation web parts should display the standard DocumentMenuCaption field.

If this is your scenario, you can modify the OnPreRender method of the Site map web part and change the DocumentMenuCaption column for each row in the DataSet so that it contain a value of the SiteMapTitle field:

if (this.smElem.DataSource is DataSet)
{
  DataSet ds = this.smElem.DataSource;
  foreach (DataRow row in ds.Tables[0].Rows)
  {
    row["DocumentMenuCaption"] = row["SiteMapTitle"];
  }
}

-ml-
0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.