1

short: A listview webpart contains a table with an ID composed of two GUID's, how do I find these?

I am working on adding some additional behaviour to a standard sharepoint listview-webpart.

Preferably I don't want to actually edit the webpart itself. I want to put javascript in a helper webpart to add some onclick events to the table rows which pass the values of the id and status columns to the helper webpart, which then displays some buttons depending on the row's status.

I searched around to see how others tackled this problem, and usually they use the webpart container div with ID WebPartWPQ _n_". The problem is that these webparts are going to be used on lots of sites, and I have no way of knowing the value of _n_.

A bit further down in the hierarchy is the main table of the view, and it also has an ID. In my test-case: {BF3FB0FA-7E7F-4920-A326-B5E46826B693}-{BD0777BD-455D-4554-A80E-8A11D990D1A5}
I figured these two guids must stand for something and could possibly be looked up.

So I went on a search through Sharepoint Manager to try to find those GUIDs, but I can't find them. Neither is the list ID, nor the original View ID, nor the web ID or the site ID.

So my question: Does anybody know what these ID's stand for, and how I can find them with my webpart code?

Aayush Kumar
  • 1,618
  • 1
  • 11
  • 31
Wuolennaj
  • 192
  • 2
  • 10
  • I think the GUIDs you see there are kept in the PersonalisationStore and used by the WebPartManager to display the correct Web Part with the correct personalisation properties. In otherwords - all server-side stuff. – James Love Mar 01 '11 at 13:05
  • That's perfectly fine. I can find the correct id's in the server-side code of the helper webpart and pass it through to the client-side code. I will see if I can find the ids in the PersonalisationStore. – Wuolennaj Mar 01 '11 at 13:30
  • Best (and only supported way) to access the IDs is via the SPWebPartManager (properties are actually stored in the content DB, in the WebParts table - http://msdn.microsoft.com/en-us/library/dd585284(v=office.11).aspx) – James Love Mar 01 '11 at 13:37
  • @JamesLove I got the WebPartManager with the following code: SPWebPartManager webPartManager = (SPWebPartManager)SPWebPartManager.GetCurrentWebPartManager(Page); By looping over the WebParts property I am able to identify the correct webpart by title (same as the list name), and get it's ID. That ID is the second of the GUID's I'm looking for. I am now looking if I can find the first GUID somewhere in its properties. – Wuolennaj Mar 01 '11 at 15:31
  • The other GUID is not one of the ID properties of the webpart object. Any ideas where I may start looking for it? – Wuolennaj Mar 01 '11 at 15:52
  • Try the ClientID property of the webpart you get via the SPWebPartManager.WebParts collection - – James Love Mar 01 '11 at 16:47
  • Tried that: the ClientID and UniqueID properties are identical to the ID property (except for some prefix). So still looking... – Wuolennaj Mar 02 '11 at 09:09
  • Tried to use Reflector to take a look at the Render method of the ListViewWebPart, but I never used Reflector before and I can't seem to open the Microsoft.Sharepoint dll. So still no luck. – Wuolennaj Mar 02 '11 at 14:19

1 Answers1

0

Have you considered using XSLT to customize the output of the webpart? You could then customize the output HTML and include any identifiers you wish so that you could reference them in your javascript. This is a pretty good description of how to do this: Overriding the presentation of an XSLT List View Web Part.

achandlerwhite
  • 191
  • 1
  • 5