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

RadContextMenu problem

0 Answers 54 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Ghost
Top achievements
Rank 1
Ghost asked on 11 Dec 2013, 07:04 AM
version: Q3 2012
I'm using context menu in RadGrid control in an iframe. But some items seem to be out of the screen, so I can't click them. Codes for js and RadGrid:
function RowContextMenu(sender, eventArgs) {
                var menu = $find("<%=RadMenu1.ClientID %>");
                var evt = eventArgs.get_domEvent();
 
                if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") {
                    return;
                }
                var index = eventArgs.get_itemIndexHierarchical();
                //document.getElementById("radGridClickedRowIndex").value = index;
                iSelectRow = index;
 
                radGrid1 = sender;
                var mt = sender.get_masterTableView();
                var row = mt.get_dataItems()[iSelectRow];
                var sStatus = row.findElement("hfStatus").value;
                var item;
                var allItems = menu.get_allItems();
                var childItem = new Telerik.Web.UI.RadMenuItem();
                menu.trackChanges();
                for (var i = allItems.length - 1; i >= 6; i--) {
                    item = allItems[i];
                    menu.get_items().remove(item);
                }
                switch (sStatus) {
                    case "U":
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("编辑测试"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_isSeparator("True"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("收样"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("暂停"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("取消"); menu.get_items().add(childItem);
                        break;
                    case "V":
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("编辑测试"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("结果录入"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("生成工作单"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_isSeparator("True"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("完成"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("暂停"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("取消"); menu.get_items().add(childItem);
                        break;
                    case "C":
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("编辑测试"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("结果录入"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_isSeparator("True"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("认可"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("暂停"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("取消"); menu.get_items().add(childItem);
                        break;
                    case "A":
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_isSeparator("True"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("激活认可"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("重新采样"); menu.get_items().add(childItem);
                        break;
                    case "S":
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_isSeparator("True"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("释放暂停"); menu.get_items().add(childItem);
                        break;
                    case "X":
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_isSeparator("True"); menu.get_items().add(childItem);
                        childItem = new Telerik.Web.UI.RadMenuItem();
                        childItem.set_text("恢复取消"); menu.get_items().add(childItem);
                        break;
                    default:
                }
                menu.commitChanges();
                menu.show(evt);
 
                evt.cancelBubble = true;
                evt.returnValue = false;
 
                if (evt.stopPropagation) {
                    evt.stopPropagation();
                    evt.preventDefault();
                }
            }

<telerik:RadGrid ID="rgDatas" runat="server" AllowSorting="True" GridLines="None"
                AllowMultiRowSelection="true" OnSortCommand="rgDatas_SortCommand" OnPreRender="rgDatas_PreRender" ShowStatusBar="True">
                <ClientSettings EnableRowHoverStyle="true">
                    <Selecting AllowRowSelect="true"></Selecting>
                    <Resizing AllowColumnResize="True" />
                    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                    <ClientEvents OnGridCreated="GridCreated" OnRowContextMenu="RowContextMenu" OnRowSelected="RowSelected" />
                </ClientSettings>
                <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
                    <Pdf PageTitle="样品列表" DefaultFontFamily="Arial Unicode MS" PageWidth="297mm" PageHeight="210mm" />
                </ExportSettings>
                <MasterTableView AutoGenerateColumns="false">
                    <Columns>
                        <telerik:GridTemplateColumn HeaderText="样品代号" DataField="SampleID" SortExpression="SampleID"
                            HeaderStyle-Width="150px" ItemStyle-Width="150px" HeaderTooltip="点击排序" UniqueName="SampleID">
                            <ItemTemplate>
                                <asp:Image ID="imgStatus" runat="server" ImageAlign="Middle" />
                                <asp:LinkButton ID="PKID" runat="server" Text='<%# Eval("SampleID"%>' Font-Underline="true"
                                    ForeColor="Blue" />
                                <asp:HiddenField ID="hfStatus" runat="server" Value='<%# Eval("Status"%>' />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="JobName" HeaderText="任务代号" SortExpression="JobName"
                            HeaderStyle-Width="150px" ItemStyle-Width="150px" HeaderTooltip="点击排序" UniqueName="JobName" />
                        <telerik:GridBoundColumn DataField="SampleName" HeaderText="样品名称" SortExpression="SampleName"
                            HeaderTooltip="点击排序" UniqueName="SampleName" HeaderStyle-Width="150px" />
                        <telerik:GridTemplateColumn HeaderText="状态" DataField="Status" SortExpression="Status"
                            HeaderStyle-Width="80px" ItemStyle-Width="80px" HeaderTooltip="点击排序" UniqueName="Status">
                            <ItemTemplate>
                                <asp:Label ID="Status" runat="server" Text='<%# Eval("Status"%>'></asp:Label>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="TemplateID" HeaderText="样品模板代号" SortExpression="TemplateID"
                            HeaderStyle-Width="100px" ItemStyle-Width="100px" HeaderTooltip="点击排序" UniqueName="TemplateID" />
                        <telerik:GridBoundColumn DataField="LoginDate" HeaderText="送样时间" SortExpression="LoginDate"
                            HeaderStyle-Width="130px" ItemStyle-Width="130px" HeaderTooltip="点击排序" UniqueName="LoginDate" />
                    </Columns>
                    <NoRecordsTemplate>
                    </NoRecordsTemplate>
                </MasterTableView>
            </telerik:RadGrid>

No answers yet. Maybe you can help?

Tags
Menu
Asked by
Ghost
Top achievements
Rank 1
Share this question
or