ListView data

5 posts, 1 answers
  1. Tino
    Tino avatar
    86 posts
    Member since:
    Jul 2017

    Posted 31 Jan 2018 Link to this post

    After getting my listview to display custom items correctly (see http://http//https//www.telerik.com/forums/custom-listview-items) I noticed that my data is not being displayed correctly. I'm getting differing results, but often the first item in the list will mirror the last, but not all of the data. See the attached screenshot. The red values show what they should be. They are all ok except the first two values of the first item. I'm quite sure my DataSource is set up correctly as I can view it in debug. Maybe you could explain how SynchronizeProperties works, as I can't find an explanation of it in the docs. Perhaps I'm using it incorrectly. The code for creating the datasource is below.

    _dataSource = new BindingList<RuleItemVisualItemDef>();
    _myRule.RuleItemDefs.ForEach(def => _dataSource.Add(
        new RuleItemVisualItemDef
        {
            RuleItemId = def.RuleItemId,
            Sequence = def.Sequence,
            Name = def.Name,
            RuleItemText = GetRuleItemTextFor(def)
        }));
    lstvwRuleItems.DataSource = _dataSource;
  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    2838 posts

    Posted 01 Feb 2018 Link to this post

    Hi Tino,

    I have investigated this and your code is ok and the items are properly synchronized. However, it appears that the layout of the text boxes needs to be forced in order the new text to be displayed. This can be done by resetting the text in the SynchronizeProperties method:
    protected override void SynchronizeProperties()
    {
        base.SynchronizeProperties();
     
        Text = "";
        _contentElement.Text = "";
     
        _idElement.Text = "";
        _sequenceElement.Text = "";
        _nameElement.Text = "";
        _ruleTextElement.Text = "";
     
        _idElement.Text = Convert.ToString(Data["RuleItemId"]);
        _sequenceElement.Text = Convert.ToString(Data["Sequence"]);
        _nameElement.Text = Convert.ToString(Data["Name"]);
        _ruleTextElement.Text = Convert.ToString(Data["RuleItemText"]);
    }

    Let me know how this works for you.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Tino
    Tino avatar
    86 posts
    Member since:
    Jul 2017

    Posted 01 Feb 2018 in reply to Dimitar Link to this post

    That's a bit unintuitive but it looks like it worked, thank you. I would still like some docs on SynchronizeProperties in order to understand it.
  4. Dimitar
    Admin
    Dimitar avatar
    2838 posts

    Posted 02 Feb 2018 Link to this post

    Hello Tino,

    We do not have docs for this, we will add such when possible. What is important about this is the use of UI Virtualization. The UI Virtualization is using visual elements only for the currently visible items. For example, you may have hundreds of items but visual elements will be created only for the ones on the screen. This improves the performance because the visual elements are really heavy compared to a simple data objects. In addition, the visual elements are reused (when scrolling for example) and only the data behind them is changed. And the SynchronizeProperties method is called when the visual item needs to be synchronized with the data. 

    I hope this will be useful. 

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Tino
    Tino avatar
    86 posts
    Member since:
    Jul 2017

    Posted 05 Feb 2018 in reply to Dimitar Link to this post

    ok thanks
Back to Top