This is a migrated thread and some comments may be shown as answers.

Show context menu for gridbuttoncolumn

3 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 1
Tina asked on 10 Apr 2013, 12:22 PM
How to show context menu on clicking button column in radgrid?

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 10 Apr 2013, 12:30 PM
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.
0
Tina
Top achievements
Rank 1
answered on 12 Apr 2013, 10:40 AM
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...."?
0
Shinu
Top achievements
Rank 2
answered on 12 Apr 2013, 10:49 AM
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.
Tags
General Discussions
Asked by
Tina
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tina
Top achievements
Rank 1
Share this question
or