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

RadListView InsertItem question..

1 Answer 115 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Carlo
Top achievements
Rank 1
Carlo asked on 09 Oct 2010, 12:36 AM
Hi,

Is there a way to make the RadListView InsertItem behave like the EditItem? What I mean is I use a list view with a pagesize of 1.
When I use the Edit functionality, the EditItem replaces the current Item displayed (while editing). When I
try to use the Insert functionality the InsertItem shows up either below or above my current Item displayed, I would like
the InsertItem to replace the current Item displayed (while inserting), much like the edit item..

Regards,
-Carlo

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 14 Oct 2010, 09:20 AM
Hello Carlo,

You can achieve the desired behavior with 3 event handlers and a flag:

protected bool IsInsertItem;
 
protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
{
    RadListView rlv = sender as RadListView;
    if (e.Item is RadListViewInsertItem)
    {
        IsInsertItem = true;
    }
}
 
protected void RadListView1_PreRender(object sender, EventArgs e)
{
    if (IsInsertItem)
    {
        RadListView rlv = sender as RadListView;
        foreach (RadListViewDataItem item in rlv.Items)
        {
            item.Visible = false;
        }
    }
}
 
protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
{
    if (e.CommandName == "Cancel" || e.CommandName == "PerformInsert")
    {
        IsInsertItem = false;
        RadListView rlv = sender as RadListView;
        foreach (RadListViewDataItem item in rlv.Items)
        {
            item.Visible = true;
        }
    }
}


Kind regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ListView
Asked by
Carlo
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or