So recently I needed to display the newest item added to a Very Large List via a dataform web part. The performance on SPQuery is pretty good as long as you return less than 2000 rows from your query. This means that you can't just return all of the list items from the datasource and then sort for the newest one. Instead I used some CAML keywords to help out. My DataSource query filtered on:
<Eq><FieldRef Name="Author" /><Value Type="Integer"><UserID /></Value></Eq>
and
<Eq><FieldRef Name="Created"/><Value Type="DateTime"><Today/></Value></Eq>
These two CAML rendering elements (for the current date, and current users ID). Helped the query return a very small number of rows, which could then be sorted by created date to show the newest.
Showing posts with label DataForm. Show all posts
Showing posts with label DataForm. Show all posts
Friday, May 1, 2009
Monday, April 27, 2009
EntityEditorWithPicker rendering
I was working with a custom lookup field type today that renders with a entity editor with picker (like a Person or Group field). I discovered that the required field validation for a SPFieldLookup fieldtype didn't actually seem to work in a dataform web part (I later found out that it works if you do a "Custom List Form" Dataform, I'll post on this later). My workaround was to embed some javascript in the page with the dataform to do some client side validation (because of the way it renders, the asp.net validator in SPD also won't help). I might write up a "how I did it" post on this in detail later, but for now I just wanted to mention an interesting thing I noticed, that the entityeditor actually renders with a bunch of hidden textareas, but the user is actually typing into a contenteditable div!
Tuesday, March 3, 2009
Dataview DataSource not showing all files...
Ran into a situation today where a Dataview web part was showing some of the items in a Library but not all... It turns out that by default the datasource only shows files and folders at the top level. All of the items that are inside of folders or subfolders will not get returned.
The solution is to go to the 'Scope' parameter of your tag and change it to 'RecursiveAll'. This will cause your query to return all items regadrless of folder level from the data source. One thing to note, if your list or library is a Very Large List you need to be careful to set your 'Filter' parameters before changing the tag to 'Recursive' (Shows all files of all folders) or 'RecursiveAll' (Shows all files and all subfolders of all folders); in our case we were doing a dataform for a very large list so we set the Filter to ID = . If you are creating your DataSource in SPD and you don't set your Filter before changing the Scope to Recursive there is a good chance SPD will time out and/or crash trying to preview your data.
More info on Data Source configuration here: http://office.microsoft.com/en-us/sharepointdesigner/HA101326861033.aspx (just note that they are changing their data source properties BEFORE they add it to the page, this will run you into the timeout issue I described above for Very Large Lists so remember to add it to the page and edit the Scope by hand in Code View).
The solution is to go to the 'Scope' parameter of your
More info on Data Source configuration here: http://office.microsoft.com/en-us/sharepointdesigner/HA101326861033.aspx (just note that they are changing their data source properties BEFORE they add it to the page, this will run you into the timeout issue I described above for Very Large Lists so remember to add it to the page and edit the Scope by hand in Code View).
Subscribe to:
Posts (Atom)