UPDATE: Really Big Hint, if you are in SPDesigner messing with forms then you’re likely doing it wrong. Seriously, Im not kidding, DON’T crack open SPD and mess with DVWP’s look at Display Templates / JS Link every single time. If you have too then this is still a handy article.

Designer is Buggy. So here are some hints when doing DVWP or DFWP including filtering lookups, where to put the cursor + others.

I can hear you saying “Ahh missing designer mode”, well no not really I like xslt so the designer mode I can live without, although there are some things that it did make so much easier, like setting a form field to a textbox via a menu, all done in code now, no menu available like in this old article https://t.co/bpbAimITHe, which is an antiquated method anyway and best to do it in javascript.

So here are some of the problems.

First DVWP.  Nightmare.  Trying to customize this, I haven’t the time to figure out all that’s wrong with this one.  Just simple things, like inserting it, convert to xslt (all of it) then ripping the guts out of it to just be what I wanted, and then having it ignore all subsequent xchanges after the initial save.  Something very strange going on so I bailed on this, to revist later.

So I used the Item Forms instead, as they are built for form entry but also lists and paging, much like I expect the dvwp to work, only they work better-ish.

So the problems.

1. Where’s my button.

Once in the code you place the cursor in the white area (not yellow) where you want your webpart and nothings working, no buttons.  This is probably well known by now but do this.

In the Code View Tools menu click the Parse HTML button.

p1

This usually sorts out the ribbon bar giving you what you need.  If it doesn’t, your cursor is in the wrong place.  Click round and about, when I wanted to add a CEWP to a page I had to select in the text of the end of a previous part, not in the white space after it for the add web part button to be active

2. Make it Easy in the XSLT

Insert your Display Form Part, then change the design to simple list mode.  It will change the xslt to something usable that you can extend without all the voodoo.

p2   p2a

 

3. Filtering

When you want to edit the query you are probably used to clicking filter and setting the menu items.  In this version I have had numerous problems when those filters are id’s or lookup fields.

I wanted to filter by a parent Id on a lookup field on my list.  So I added the display part and set the xslt to easy.  Next I know the Id of the parent is on the QueryString as pid param.

So I added the Parameter by clicking the Parameters ribbon button and setting the various values the name and the type(QS) and its name.

p3

p3a

Great it inserted it into the ParamBindings and Params of the XSLT.  Now when I click the filter button it appears in the drop-down for selection.  If you save the page and run this it will not work. it will return everything or it might return one row, that’s another problem though, but its not filtering.

p3b

This is because the SPDataSource has had its query modified but it has not inserted the SelectParameter relating to the param you are querying against.  I had to manually enter it.

<SelectParameters>

<asp:QueryStringParameter QueryStringField="ID" DefaultValue="1" Name="ParentIdeaId"></asp:QueryStringParameter>

</SelectParameters>

Major bug there MS.

So I saved that and run the page, did it filter.  “Did it eck as like“.  Because the Query that this set up was querying for text not ID, the filter box doesn’t ask or figure out what you are trying to filter on so you have to edit the query as well to get the types right, in this case for a lookup field.  This is what I set mine to.

<FieldRef Name="ParentSubmission"  LookupId="TRUE"/><Value Type="Lookup">{ParentItemId}</Value>

4. Returning one item

You have inserted your display form item, ran it and it shows 1 result. You look at the paging option in the menu and it says all items.  It’s lying.  Select this option and watch the xslt change.  you might find it shows all the options then.

p4

 

Technorati Tags:
Advertisements