0

I have Object Name Roption and I want to remove third element inside Add Task.

This one => "{ text: "Child", alias: "addsubbelowchild", action:menuAction}"

I am using Delete Roption.items[0].items[2].

It works but Roption.items[0].items.length returns the same count number even after deleting.

Is it really deleting or just making it undefined?

 var Roption = { width: 150, items: [
                { text: "Add Task",  alias: "addtask", type: "group" , width : 130 , items : 
                    [   
                        { text: "Sibling",  alias: "addsiblingbelow", action : menuAction},
                        { text: "Child First", alias: "addsubaboveDirect", action: menuAction },
                        { text: "Child Last",  alias: "addsubbelowDirect", action: menuAction },
                        { text: "Child",  alias: "addsubbelowchild", action:menuAction},
                        { text: "Advanced Add",  alias: "advancedadd", type: "group" , width : 120 , items :
                            [
                                { text: "Sibling", alias: "addsibling", type: "group" , width : 120 ,items :
                                    [
                                        { text: "Below",  alias: "addsiblingbelow", action: menuAction },
                                        { text: "Above",  alias: "addsiblingabove", action: menuAction }
                                    ]
                                },
                                { text: "Child", alias: "addsubtask", type: "group" , width : 120 ,items :
                                    [
                                        { text: "First", alias: "addsubabove", action: menuAction },
                                        { text: "Last", alias: "addsubbelow", action: menuAction }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
                , onShow: applyrule
                , onContextMenu: BeforeContextMenu
                , onClose : AfterContextMenu
};
function menuAction(row) {}
function BeforeContextMenu(row) {}
function applyrule(row) {}
function AfterContextMenu(row) {}
8
  • 1
    if you want to delete array item, you may use splice method Commented Oct 18, 2013 at 8:13
  • @Anton delete returns True... Commented Oct 18, 2013 at 8:18
  • 1
    items is an array right? and i wrote wrong, it doesn't return null but it returns undefined like this [1, 2, undefined × 1, 4] Commented Oct 18, 2013 at 8:20
  • 1
    @RiteshChandora Roption is an object, and items are arrays in both cases Commented Oct 18, 2013 at 8:29
  • 1
    Roption.items[0].items.push({"test":"testing"}); try this and you'll see it works @RiteshChandora Commented Oct 18, 2013 at 8:30

1 Answer 1

1

Try using .splice(index,howmany)

Roption.items[0].items.splice(2,1);
Sign up to request clarification or add additional context in comments.

2 Comments

Actually it works.. but splices works on array prototype... and its object.. Correct me if I am wrong!!
Items is an array with objects inside the array @RiteshChandora

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.