1

is there a way that is not too complicated too refresh just a dataview web part on a sharepoint site when loading the page in _spBodyOnLoadFunctionNames.push using javascript?

What I've done is created a document library and added some columns containing metadata. When a document is uploaded a use a workflow to populate some of these fields from AD, and the others has to be filled in by the user.

Now, when a document is uploaded to a doucument library with added columns it immediately goes to the edit item page for the added columns. The problem is the workflow is not quite fast enough to populate the required fields by the time it displays.

i have tried to add a custom edit item web part to the page and enable the asynchronous load which works perfectly, however I get an error that goes something about expecting an object. Thus I want to manually refresh the web part.

Any thoughts?

2 Answers 2

1

You can try another simple way, by leveraging ASP.Net, since the List Webpart is contained inside a asp:UpdatePanel, you can update that UpdatePanel via:

var ListID = 'BAC6C3F7-4E5F-4BA5-A576-5DF66C33C83E'; // just an example UID
__doPostBack($('table[id|="{'+ListID.toUpperCase()+'}"]').attr('id'), '');

ListID is the ID of your List (without curly braces), since the Table we are looking for in html-markup has the ID of the List concatenated with another ID (I am not entirely sure which one that is).

html-Markup looks like this:

<table id="{BAC6C3F7-4E5F-4BA5-A576-5DF66C33C83E}-{50CD32F2-352E-4E0C-ABDE-B0AB619A2F94}" class="ms-listviewtable" .... >

sadly this option is not very well documented.

1

You can reload a XSLTListViewWebpart with ajax by selecting Edit Web Part -> AJAX Options -> Enable Asynchronous Load. Here you can also set it to refresh on a given interval.

Now you say you have "enable the asynchronous load", and this works, so what you can do if you want to trigger this load manually is to select Show Manual Refresh Button in the same settings, and then you can use JavaScript to manually click this button!
Example with jQuery:

$('#ManualRefresh').parent().click();

Another interesting trick is that by enabling asynchronous load the web part can be re-injected into the DOM, this is not possible without this setting enabled as the filtering and other script-dependent solutions will fail.
You can do this with jQuery .load, or with .post like this:

$.post(window.location.pathname, function(d) {
  $('[webpartid]').html($(d).find('[webpartid]')); 
});
1
  • Thanks for the reply. I will try the solutions you proposed.
    – Carel
    Commented Sep 28, 2012 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.