Only Edit Fields on Current View

Jul 2, 2012 at 7:41 PM

I really like this project, it definitely fills in a hole in the out-of-the-box functionality.  One additional feature that I had wanted was to only batch edit the fields that were visible on the current view.  This would allow the user to have an experience more like Datasheet mode but in a simpler UI.

To achieve this, I had to make a small change to TamTam.SP2010.BatchEdit.js file:

url: webUrl + '/_layouts/TamTam.SP2010.BatchEdit/BatchEdit.aspx?items=' + this.selectedItems + "&web=" + this.web.get_id() + '&source=' + SP.ListOperation.Selection.getSelectedList() + '&view=' + ctx.view,        

Then in then in BatchEdit.aspx.cs I made these changes:

using (SPWeb web = SPContext.Current.Site.OpenWeb(new System.Guid(webId))) {
SPList list = web.Lists[new System.Guid(listId)];
SPView viewToUse = list.Views[new System.Guid(Request["view"])];
foreach (string viewFieldInternalName in viewToUse.ViewFields) {
SPField field = list.Fields.GetField(viewFieldInternalName);
...                       

With some extra error trapping, it allowed me to modify the code to only display the fields from the current view.  Worked great for me, thanks for creating and sharing!