Show context menu for gridbuttoncolumn

4 posts, 1 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 10 Apr 2013 Link to this post

    How to show context menu on clicking button column in radgrid?
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Apr 2013 Link to this post

    Hi,

    Try the following code to show context menu on right click of button.
    c#:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
      if (e.Item is GridDataItem)
      {
       GridDataItem item = (GridDataItem)e.Item;
       LinkButton btn = (LinkButton)item["Uniquename"].Controls[0];
       btn.OnClientClick = "showMenu(this, event); return false;";
      }
    }
    JS:
    function showMenu(sender, args) {
            var contextMenu = $find("<%= RadContextMenu1.ClientID %>");
            contextMenu.show(args);
    }

    Thanks,
    Shinu.
  3. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 12 Apr 2013 Link to this post

    Thanks..it works.is it possible to truncate cell text in a column for eg:if the text is "i have a long text" i want to show "i have...."?
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Apr 2013 Link to this post

    Hi,

    Try the following code.
    C#;
    void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
            if (e.Item is GridDataItem)
            {
              GridDataItem item = (GridDataItem)e.Item;
                if (item["UniqueName"].Text.Length > 5)
                {
                    item["UniqueName"].Text = item["UniqueName"].Text.Substring(0, 5) + "...";
                }
           }
    }
    Thanks,
    Shinu.
Back to Top