Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Sitecore, how to Reload the Content Editor with Parent Item on Modal Dialog Ok?

I'm using Sitecore 8. I have custom ModalDialog, it is getting triggered by a button in the Ribbon (Content Editor).

On the Dialog backend, I'm removing the scope Item. So OnOk I want Refresh the Parent and load Parent item on dialog close.

I have the following code but it is not working,

protected override void OnOK(object sender, EventArgs args)
    {

        //ScopeItem - Current Item in the Content Tree
        //db - Database
        RemoveItem(ScopeItem, db);


        //ScopeItemParent- Current Item's Parent Item
        Context.ClientPage.SendMessage(this, string.Format("item:updated(id={0})", ScopeItemParent.ID));
        Context.ClientPage.SendMessage(this, string.Format("item:refreshchildren(id={0})", ScopeItemParent.ID));
        Context.ClientPage.ClientResponse.Timer(string.Format("item:load(id={0})", ScopeItemParent.ID), 100);

        base.OnOK(sender, args);
    }

Thanks for your help.

like image 608
Sakthivel Avatar asked Jan 20 '26 21:01

Sakthivel


1 Answers

The normal Delete command does exactly that. It simply calls Sitecore.Shell.Framework.Items.Delete(), which then runs the uiDeleteItems client pipeline. You should be able to do the same by doing something like this:

protected override void OnOK(object sender, EventArgs args)
{
    //ScopeItem - Current Item in the Content Tree
    Sitecore.Shell.Framework.Items.Delete(new[] { ScopeItem });

    base.OnOK(sender, args);
}
like image 182
Ben Golden Avatar answered Jan 25 '26 23:01

Ben Golden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!