Showing posts with label reorderlist. Show all posts
Showing posts with label reorderlist. Show all posts

Wednesday, March 21, 2012

Delete and edit in ReorderList

Hi.

Is is possible to delete and edit the listitems in the ReorderList? Any examples of this?


thanks

-T

I have created the DeleteCommand event in the reorderList.. It looks like

protected void ReorderList1_DeleteCommand(object sender, ReorderListCommandEventArgs e)
{
this.ReorderList1.Items.Remove(e.Item);
}

But how do I trigger this event?
I could add a "linkbutton"(or something else) in the itemtemplate, but this obviously doesn't send an ReorderListCommandEventArgs, so I dont know what item in the list i selected..


Anyone?


Hi,

You just need to set the CommandName property of the LinkButton to "delete" to fire this event.


Thanks!

That worked.
I implemented the ItemCommand, instead of the DeleteCommand as I wrote earlier. Then I could do both editing and deleting with the same event:

protected void ReorderList1_ItemCommand(object sender, ReorderListCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
//Code for deleting the item
}

if (e.CommandName == "Edit")
{
//Code for editing the item
}
}


Got a new problem now...

When i want to save after editing, I use the following code:

if (e.CommandName.Equals("Save"))
{
List<myReorderListItem> list = (List<myReorderList>)Session["data"];

TextBox tb = (TextBox)e.Item.FindControl("tbEdit");
myReorderListItem m = new myReorderListItem();

m.Title = tb.Text;
m.Priority = e.Item.ItemIndex + 1;

list.RemoveAt(e.Item.ItemIndex);
list.Insert(e.Item.ItemIndex, m);

ReorderList1.EditItemIndex = -1;
myReorderList.saveDataToSession(list);
}

It finds the textbox control, but tb.Text is the same text that was in the textbox, before I edited it...

How can I get the "new/edited" text? (What actually is in the textbox)


alert(document.getElementById('tbEdit').value); returns the right value, but I wasn't planning on doing any javascript on this page..

tried this.Page.FindControl("tbEdit") also, but that also returns the textbox with the Text before it was edited!

Define itemTemplate for Reorderlist at runtime

Hi,

I am able to get the reorderlist control to work my supplying a datasource and writing the markup for the itemTemplate.

How do i go about setting the itemTemplate at runtime depending on the datasource?

I tried programatically creating ReorderListItems, and collections but nothing got rendered.

I see that the ReorderList has an itemTemplate property, will this help?

OK. I have figured it out how to do it by creating a class that implements the ITemplate interface.

The problem i have now is i am using the reorderlist control within the accordian control.

For example i have a menu with 3 selections. This is controlled by the accordian.

Within the each accordian pane, i create a reorderlist, therefore there are 3 reorderlists, one within each accordian pane. This works fine, and i am able to reorder the items in the list. However, it seems that when i try to move items in the 2nd/3rd pane, they all disappear into the 1st pane. Is this because even though it looks like the accordian is shrinking and expanding, the actual working area for the reorder list is already defined, hence when pane 1 is minimised with pane 2 open, pane 2 reorderlist is actually already ontop of pane 1 reorder list??

I hope the above makes sense.