This is a migrated thread and some comments may be shown as answers.

ListView data

4 Answers 113 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Tino
Top achievements
Rank 1
Tino asked on 01 Feb 2018, 01:02 AM

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;

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 01 Feb 2018, 10:47 AM
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.
0
Tino
Top achievements
Rank 1
answered on 01 Feb 2018, 08:48 PM
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.
0
Dimitar
Telerik team
answered on 02 Feb 2018, 02:13 PM
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.
0
Tino
Top achievements
Rank 1
answered on 06 Feb 2018, 01:48 AM
ok thanks
Tags
ListView
Asked by
Tino
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Tino
Top achievements
Rank 1
Share this question
or