This question relates to ASP.NET RadListView.
I have added records to a RadListView by using the following JavaScript:
radListView.appendData(data.Data);
Everything is done using JavaScript for this RadListView. I now have a new requirement that requires me to remove all the records added during the last appendData call. How would I do this using JavaScript?
The RadListView is template-based and uses the template below.
<LayoutTemplate>
<div id="items"></div>
<div id="pagerContainer"></div>
</LayoutTemplate>
<ItemTemplate>
<div class="recordContainer">
<div class="subject">#=Subject#</div>
<div class="message" >#=MessageText#</div>
<div class="author">#=Author#</div>
</div>
</ItemTemplate>
The way I was going to handle this situation was by keeping track of the number of data items added in the last appendData call. Let's say this number is 20. I would then find the last 20 DOM elements having a class of "recordContainer" and remove those DOM elements. The sample code in jQuery would be as mentioned below, which I haven't tried. However, you might be able to help me figure out a better way to do this, if there is one.
$("div#items div.recordContainer").slice(-20).remove();