
| case "PerformInsert": |
| rgdStatusList.Columns.FindByUniqueName("Active").Visible = true; |
| rgdStatusList.Columns.FindByUniqueName("Archived").Visible = false; |
| AddStatus(e); |
| break; |
| protected void AddStatus(Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| Telerik.Web.UI.GridEditableItem insertItem = e.Item.OwnerTableView.GetInsertItem(); |
| //e.Item as Telerik.Web.UI.GridEditableItem; |
| Status mStatus = new Status(); |
| AdminManager mAdminManager = new AdminManager(); |
| //Pull in all needed info to create a new record in the database. |
| mStatus.StatusDescription = (insertItem["StatusDescription"].Controls[0] as TextBox).Text; |
| mStatus.Active = (insertItem["Archived"].Controls[0] as CheckBox).Checked; |
| mStatus.CommunityID = ParentKNPage.CoPID; |
| try |
| { |
| mAdminManager.InsertStatus(mStatus); |
| } |
| catch (Exception ex) |
| { |
| rgdStatusList.Controls.Add(new LiteralControl("Unable to insert Status. Reason: " + ex.Message)); |
| } |
| } |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| function insertPlaceholder() { |
| var placeholerSelector = $find("<%= PlacholderSelectBox.ClientID %>"); |
| var editor = $find("<%= TemplateEditor.ClientID %>"); |
| editor.pasteHtml(placeholderSelector.get_value()); |
| } |
| </script> |
| </telerik:RadCodeBlock> |
I have a RadGrid with an associated RadContextMenu. When I right-click a row on the grid and click one of the context menu items I need to get at the selected row in the context menu's event handlers. However, I found that the SelectedItems collection is empty.
I was able to work around this by adding an OnRowContextMenu handler, with code like this:
function Grid_OnRowContextMenu(sender, args)
{
var index = args.get_itemIndexHierarchical();
var row = sender.MasterTableView.get_dataItems()[index];
row.set_selected();
}
This partially works, but it seems like there should be an easier way to do this. For one, it doesn't deselect other selected rows. Right now I have to add this client-side handler to every single one of my grids. It seems like there should be some sort of property on the grid that enables row selection on right click.
One other problem I have is that I do not want the context menu to show when the grid has no rows. With the old RadGrid I was able to check the row's ItemType property. If it was "NoRecordsItem", I would not show the context menu.
| var editor = GetRadEditor("<%=RadContent.ClientID%>"); |
| editor.SetFocus(); |
Am I missing something? Thanks
