Is it possible to refresh a related items control programmatically
I have some code which creates a word document, updates the lookup field so that it is related to the parent (edit) form. Once created, I can trigger the form to reload using window.location.reload(), however I'd like to be able to update the related items webpart only.
Is this possible?
Kind regards
Andy
Is this possible?
Kind regards
Andy
Dear Andy,
Please check this code:
Please check this code:
Code: Select all
fd.relatedItems(0).data('ctx').clvp.RefreshPagingEx('');
Hi Alex, thanks for confirming, I eventually figured out the order of the controls I needed to refresh - however I seem to have found an issue - I have one related item control that is using a caml query to filter the results:
<Toolbar Type="None" />
<ViewFields>
<FieldRef Name="Remove" DisplayName="Remove"></FieldRef>
<FieldRef Name="ChangeDetails" DisplayName="Edit Details"></FieldRef>
<FieldRef Name="DBClientLookup" DisplayName="Client Name"></FieldRef>
<FieldRef Name="ClientType" DisplayName="Client Type"></FieldRef>
</ViewFields>
<Query>
<Where>
<Eq>
<FieldRef Name="RelatedMatterLookup" LookupId="TRUE" />
<Value Type="Lookup">{ID}</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
<ParameterBinding Name="ID" Location="QueryString(ID)" />
</ParameterBindings>
</View>
It gets the ID from the querystring and passes that as 'ID' in the CAML query - note this is the only related item control on the form that uses the above schema.. when I refresh this control using the code above I get 'no results' in my related items.
Do you know why this might be happening? The CAML is there because the originating list is over 5000 items and this was the only way to make the control 'viewable'.
<Toolbar Type="None" />
<ViewFields>
<FieldRef Name="Remove" DisplayName="Remove"></FieldRef>
<FieldRef Name="ChangeDetails" DisplayName="Edit Details"></FieldRef>
<FieldRef Name="DBClientLookup" DisplayName="Client Name"></FieldRef>
<FieldRef Name="ClientType" DisplayName="Client Type"></FieldRef>
</ViewFields>
<Query>
<Where>
<Eq>
<FieldRef Name="RelatedMatterLookup" LookupId="TRUE" />
<Value Type="Lookup">{ID}</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
<ParameterBinding Name="ID" Location="QueryString(ID)" />
</ParameterBindings>
</View>
It gets the ID from the querystring and passes that as 'ID' in the CAML query - note this is the only related item control on the form that uses the above schema.. when I refresh this control using the code above I get 'no results' in my related items.
Do you know why this might be happening? The CAML is there because the originating list is over 5000 items and this was the only way to make the control 'viewable'.
Yep, I've put it in the View section for the related items control within Forms Designer. I've modified it a little since this original post, so I'll repost the xml here:
<View>
<XslLink>main.xsl</XslLink>
<JSLink>clienttemplates.js</JSLink>
<Query>
<Where>
<Eq>
<FieldRef Name="RelatedMatterLookup" LookupId="TRUE" />
<Value Type="Lookup">{ID}</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name="Remove" DisplayName="Remove"></FieldRef>
<FieldRef Name="ChangeDetails" DisplayName="ChangeDetails"></FieldRef>
<FieldRef Name="DBClientLookup" DisplayName="DBClientLookup"></FieldRef>
<FieldRef Name="ClientType" DisplayName="ClientType"></FieldRef>
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Aggregations Value="Off" />
<Toolbar Type="None" />
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
<ParameterBinding Name="ID" Location="QueryString(ID)" DefaultValue="0" />
</ParameterBindings>
</View>
Note, for this to work as a filter the Related Items data source settings are All Items view, with 'Show all items from the view' selected. It didn't appear to work when I put a filter there as well as in the xml. Hope that helps.
<View>
<XslLink>main.xsl</XslLink>
<JSLink>clienttemplates.js</JSLink>
<Query>
<Where>
<Eq>
<FieldRef Name="RelatedMatterLookup" LookupId="TRUE" />
<Value Type="Lookup">{ID}</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name="Remove" DisplayName="Remove"></FieldRef>
<FieldRef Name="ChangeDetails" DisplayName="ChangeDetails"></FieldRef>
<FieldRef Name="DBClientLookup" DisplayName="DBClientLookup"></FieldRef>
<FieldRef Name="ClientType" DisplayName="ClientType"></FieldRef>
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Aggregations Value="Off" />
<Toolbar Type="None" />
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
<ParameterBinding Name="ID" Location="QueryString(ID)" DefaultValue="0" />
</ParameterBindings>
</View>
Note, for this to work as a filter the Related Items data source settings are All Items view, with 'Show all items from the view' selected. It didn't appear to work when I put a filter there as well as in the xml. Hope that helps.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 16 guests