ListView Item reselektieren

Das ModalDialog-Framework in SharePoint ist eine nette Sache. Leider hat es das Problem, dass ausgewählte Listenelemente nach dem Aktualisieren der Seite wieder deselektiert sind.

Möchte man über den Ribbon bzw. mehrere Dialoge einen „Workflow“ abbilden ist das Verhalten sehr störend (z.B. wenn ein Benutzer mehrere Dialog öffnen muss um einen bestimmten Status auf ein Element zu setzen).

Die gute Nachricht: Durch das Neuladen der Seite mittels SP.UI.ModalDialog.RefreshPage wird ein POST ausgelöst.
Somit kann man sich die Daten in einem HiddenField speichern. Einfachste Lösung wäre hier ein Delegate-Control, das die ID des selektierten Elemtents wieder ausliest.

Doch wie selektiert man das Element wieder?

Microsoft hat bei der Entwicklung des Userinterfaces schon an alles gedacht. Ich musste allerdings lange suchen, bis ich die richtige Funktion gefunden habe:

ToggleItemRowSelection2(ctxCur, tr, fSelect, fUpdateRibbon)

Die Funktion stammt aus der SharePoint core.js.

Die Parameter:

  • ctxCur: Der aktuelle SharePoint Context der Seite
  • tr: Das DOM-Objekt der auszuwählenden TableRow
  • fSelect: Ein bool-Wert, der angibt ob das Element selektiert oder deselektiert wird
  • fUpdateRibbon: bool, Gibt an ob die Command-UI (Ribbon) aktualisiert werden soll

Hier ist ein Ausschnitt aus meiner Lösung. Voraussetzung ist ein HiddenField, das per Klick-Event die ID der selektierten Zeile speichert.

$(function () {
	// add click event to row
	$('').click(function () {
		var iidAttributeValue = $(this).attr('iid');
		var iid = iidAttributeValue.split(',');
		if (iid.length == 3) {
			$('#thehiddenfieldid').val(iid[1]);	// set selection to hidden field

	// read value from hidden field and reselect the row
	var currentCtx = GetCurrentCtx();	// method from CUI.js
	var itemId = $('#thehiddenfieldid').val();		// get id from hiddenfield
	var jTr = $('tr[iid*=",' + itemId + ',"]:first');	// tr to select

	if (!CUI.ScriptUtility.isNullOrUndefined(currentCtx) && jTr.length > 0) {
		ToggleItemRowSelection2(currentCtx, jTr[0], true, true);


131 Kommentare

  1. Great ¡V I should definitely pronounce, impressed with your website. I had no trouble navigating through all tabs and related info ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those who add forums or anything, site theme . a tones way for your client to communicate. Nice task..

  2. Hello there! This is kind of off topic but I need some advice from an established blog. Is it hard to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about creating my own but I’m not sure where to begin. Do you have any ideas or suggestions? With thanks

  3. Hello! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly? My site looks weird when browsing from my iphone4. I’m trying to find a theme or plugin that might be able to correct this issue. If you have any recommendations, please share. Many thanks!

  4. Magnificent beat ! I would like to apprentice while you amend your web site, how could i subscribe for a blog web site? The account helped me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear idea

  5. Do you mind if I quote a few of your posts as long as I provide credit and sources back to your site? My blog is in the very same niche as yours and my visitors would truly benefit from a lot of the information you provide here. Please let me know if this okay with you. Thank you!

  6. It’s laborious to seek out knowledgeable folks on this topic, however you sound like you recognize what you’re speaking about! Thanks

  7. fantastic points altogether, you just gained a brand new reader. What would you recommend in regards to your post that you made some days ago? Any positive?

  8. It’s truly a nice and helpful piece of information. I am satisfied that you simply shared this useful info with us. Please keep us informed like this. Thank you for sharing.

  9. Wow! This can be one particular of the most beneficial blogs We’ve ever arrive across on this subject. Actually Great. I am also a specialist in this topic so I can understand your effort.

  10. Hi there I am so excited I found your blog page, I really found you by error, while I was looking on Google for something else, Regardless I am here now and would just like to say cheers for a incredible post and a all round exciting blog (I also love the theme/design), I don’t have time to browse it all at the minute but I have book-marked it and also included your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the excellent work.

  11. Wonderful paintings! That is the kind of information that are supposed to be shared around the web. Disgrace on Google for now not positioning this post upper! Come on over and discuss with my website . Thank you =)

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.