How to get List item's attribute in context menu's selection?

2 posts, 0 answers
  1. Gangatharan
    Gangatharan avatar
    3 posts
    Member since:
    Mar 2018

    Posted 21 Mar 2018 Link to this post

    I have two RadListBox. Data in first box is populated from database using RadListBoxItem and I have set an attribute for each item. In the second box, I've created custom context menu. After I adding the item from first box to second box, user can select some option using the context menu. On context menu selection, I need to get the Attribute I set before and update the attribute value according to the context menu selection so I can used it for later process.Currently, I unable to even the attributes I set previously using the context menu's javascript. Please guide how to read ListItem's attribute and update the attribute to a new value.

     

    This is how I add the item to the first box with attribute.

    this._sortingList = new List<Sorting>();
    this._sortingList = DBConnection.getSortingList();
     
    foreach (var s in this._sortingList)
     {
            RadListBoxItem item = new RadListBoxItem();
            item.Text = s.Description;
            item.Value = s.Id.ToString();
            item.Attributes["myorder"] = "0";
            this.RadListBox1.Items.Add(item);
    }

     

    Thus custom context menu javascript.

        function showContextMenu(sender, e) {
        var menu = $find("<%= cm1.ClientID %>");
        var rawEvent = e.get_domEvent().rawEvent; menu.show(rawEvent);
        e.get_item().select();
        $telerik.cancelRawEvent(rawEvent);
     
    }
    function onItemClicked(sender, e) {
        var listBox = $find("<%= RadListBox1.ClientID %>");
        var listItem = listBox.get_selectedItem();
        var menuItem = e.get_item();
        if (menuItem.get_text() == "Ascending"){
            alert(listItem.get_attributes().getAttribute("myorder"));
        }
        else if (menuItem.get_text() == "Descending") {
            alert(listItem.get_attributes().getAttribute("myorder"));
        }
    }
  2. Gangatharan
    Gangatharan avatar
    3 posts
    Member since:
    Mar 2018

    Posted 21 Mar 2018 in reply to Gangatharan Link to this post

    Sorry, posted wrongly in wrong control.
Back to Top