UpdateAllFields and custom fields

4 posts, 0 answers
  1. Charles
    Charles avatar
    41 posts
    Member since:
    Mar 2012

    Posted 14 Jan 2015 Link to this post

    Hi

    I've noticed that in 2014.3.1021 there have been some performance enhancements to UpdateAllFields.  I'm not entirely sure what they are, but if I was to guess I'd say the document is no longer being layed out, mesaured and arranged after each field update.

    This has, sadly, broken one of my custom fields.

    I have a sort-of-cross reference field - it returns the page number of a custom AnnotationRangeStart.  It does this in basically the same way as PageField.

    Following the update to this version, the page number is always returned as '1' during UpdateAllFields.  This seems to be because the layout only reports a single SectionLayoutBox in the DocumentLayoutBox.

    I see from the PageField source two internal virtual methods that you use to workaround this issue: SaveState and RestoreState.  As these are internal and not protected internal, I can't do the same.

    My current workaround is to run Document.UpdateLayout() while this field is updating, which isn't ideal.  Do you have any better ideas, or would you consider changing the accessibility of these internal state management methods?







  2. burk
    burk avatar
    9 posts
    Member since:
    Feb 2014

    Posted 15 Jan 2015 in reply to Charles Link to this post

    If i understand, you must catch merge fields first with:
    private List<MergeField> mergeFields;
    private void GetMergeFieldStarts()
            {
                #region MergeField'ların Bulunması
     
                mergeFields.Clear();
                foreach (FieldRangeStart fieldStart in radRichTextBox.Document.EnumerateChildrenOfType<FieldRangeStart>())
                {
                    if (fieldStart.Field is MergeField)
                    {
                        mergeFields.Add(fieldStart);
                    }
                }
                #endregion
            }
    And you can get your merge fields propertyPaths with foreach.
    If you catch true Field you can get this control with
    foreach (var item in mergeFields)
                {
                    if (((MergeField)item.Field).PropertyPath == "YourPropertyPath")
                    {
                        FieldRangeStart field = (FieldRangeStart)item;
                        var fieldsControl= FindControlFieldMethod(field.Parent);
     
                        YourControlType control= (YourControlType)fieldsControl;
                        
                        
     
     
                    }
     
     
                }
    And If find true PropertyPath you can find your control with:
    private DocumentElement FindControlFieldMethod(DocumentElement documentElement)
            {
                if (documentElement is YourControlType)
                {
                    return documentElement;
                }
                else
                {
                    return FindControlFieldMethod(documentElement.Parent);
                }
     
            }
  3. UI for WPF is Visual Studio 2017 Ready
  4. Charles
    Charles avatar
    41 posts
    Member since:
    Mar 2012

    Posted 15 Jan 2015 in reply to burk Link to this post

    Thanks for the answer, but I'm not sure how this is relevant to my question.  I don't have any MergeFields, and I don't have any controls to find.

    My issue is as I described: during UpdateAllFields, the Layout is not valid and I can't get correct PageNumbers.
  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 15 Jan 2015 Link to this post

    Hi Charles,

    There is currently an issue with the UpdateAllFields() method which does not cause the document layout to be wrong, but updates the fields with wrong values. This is logged in our public portal here and as mentioned in the item, the workaround is to update each field separately. Could you try this out and let us know how it works for you?

    Regards,
    Petya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top