【问题标题】:RadGrid RadComboBox Client Popup HelpRadGrid RadComboBox 客户端弹出帮助
【发布时间】:2011-03-01 03:33:22
【问题描述】:

需要一些帮助来解决这个问题。我想向我的 RadGrid 添加一个 On RowClick 事件处理程序,以在 RadGrid Editform 模式下处理来自 RadComboBox 的选择。我想做的是,当用户从组合框中进行选择时,显示一个 RadWindow 以允许用户在 RadGrid Editform 的文本框中显示其他选择。到目前为止,我没有显示任何内容,甚至没有显示警报框

  function RowCreated(rowObject) {
       alert("Row with Index: " + rowObject.Index + " was created");
   }

   function RowSelected(sender, args) {
       alert("row selected");
       inputFieldValue = args.getDataKeyValue("Type");
       alert(inputFieldValue);
   }

   function RowClick(rowIndex, e) {
       alert("row Clicked");
       var sourceElement;
       alert(rowIndex);
   }

网格的附件发生在客户端事件标签中

<telerik:RadGrid ID="securityGrid" runat="server" AllowPaging="True"  AllowSorting="True" AutoGenerateColumns="false" Height="99.9%" AllowCustomPaging="true">
                              <MasterTableView ShowFooter="true"  AutoGenerateColumns="False" AllowSorting="true" AllowPaging="true" EnableViewState="true" ClientDataKeyNames="HKey" DataKeyNames="HKey">
                                    <NoRecordsTemplate>
                                        <div align="center" style="font-weight: bold; font-size: 16px; color: Green; width: 100%;">
                                            There Are No Records To Display. Please Select Another View.</div>
                                    </NoRecordsTemplate>
                                    <Columns>
                                        <telerik:GridBoundColumn UniqueName="EHKey" Visible="false" DataField="EHKey" />
                                        <telerik:GridCheckBoxColumn UniqueName="Active" HeaderText="Active" DataField="Active"
                                            ColumnEditorID="ReportEditor">
                                            <ItemStyle Width="70" />
                                            <HeaderStyle Width="70" />
                                        </telerik:GridCheckBoxColumn>
                                        <telerik:GridDropDownColumn UniqueName="UILocation" DataSourceID="UILocation_DS"
                                            HeaderText="UI Location" DataField="UILocation" ListTextField="Description" ListValueField="PrimaryKey"
                                            DropDownControlType="RadComboBox" ColumnEditorID="ReportEditor">
                                            <ItemStyle Width="20%" Height="18" />
                                            <HeaderStyle Width="20%" />
                                        </telerik:GridDropDownColumn>
                                        <telerik:GridDropDownColumn UniqueName="Type" DataSourceID="SecurityType_DS" HeaderText="Type"
                                            DataField="SecurityType" ListTextField="Description" ListValueField="PrimaryKey"
                                            DropDownControlType="RadComboBox" ColumnEditorID="ReportEditor">
                                            <ItemStyle Width="120" Height="18" />
                                            <HeaderStyle Width="120" />
                                        </telerik:GridDropDownColumn>
                                        <telerik:GridBoundColumn UniqueName="Item" HeaderText="Item" DataField="ItemList"
                                            ColumnEditorID="ReportEditor">
                                            <ItemStyle Width="10%" />
                                            <HeaderStyle Width="10%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridDropDownColumn UniqueName="Access" DataSourceID="AccessType_DS" HeaderText="Access"
                                            DataField="AccessType" ListTextField="Description" ListValueField="PrimaryKey"
                                            DropDownControlType="RadComboBox" ColumnEditorID="ReportEditor">
                                            <ItemStyle Width="120" />
                                            <HeaderStyle Width="120" />
                                        </telerik:GridDropDownColumn>
                                        <%-- <telerik:GridBoundColumn UniqueName="ItemList" Visible="false" DataField="ItemList" />--%>
                                        <telerik:GridEditCommandColumn HeaderText="Edit" ButtonType="ImageButton" UniqueName="EditCommandColumn">
                                            <ItemStyle Width="40" CssClass="WATSImageButton" />
                                            <HeaderStyle Width="40" />
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridButtonColumn UniqueName="DeleteCommandColumn" ButtonType="ImageButton"
                                            CommandName="Delete" HeaderText="Del" ConfirmTitle="Delete Strategy Milestone!"
                                            ConfirmText="Are you sure you want to delete this record?" ConfirmDialogType="RadWindow"
                                            ConfirmDialogHeight="100" ConfirmDialogWidth="350">
                                            <ItemStyle Width="35" CssClass="WATSImageButton" />
                                            <HeaderStyle Width="35" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                    <EditFormSettings>
                                        <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="0" Width="100%"
                                            CssClass="masterTable" />
                                        <FormTableStyle CellSpacing="0" CellPadding="0" Width="50%" />
                                        <FormStyle Width="100%" BackColor="#ffffe1"></FormStyle>
                                        <EditColumn ButtonType="ImageButton" CancelText="Cancel" UpdateText="Update" InsertText="Add" />
                                    </EditFormSettings>
                                </MasterTableView>
                                <ClientSettings>
                                    <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                                        <ClientEvents OnRowClick="RowClick" OnGridCreated="GridCreated" />
                                    <Selecting AllowRowSelect="false" />
                                    <ClientEvents />
                                </ClientSettings>
                            </telerik:RadGrid>

【问题讨论】:

  • 如何附加 RowClick 事件?

标签: asp.net ajax telerik radgrid radcombobox


【解决方案1】:

调试您的 js 代码以查看它的哪一部分得到处理以及是否发生错误。这可以帮助您找出问题所在。

【讨论】:

  • 通过在代码中添加警报进行调试并没有产生太多效果,因为它似乎偶尔会运行并且没有按预期运行。
【解决方案2】:

看下面一行:

alert("Click on row instance: " + eventArgs.get_itemIndexHierarchical());

您尚未定义 eventArgs。这是函数的第一行,因此当您单击该行时“什么都没有”发生是有道理的。

改变你的功能如下:

function RowClick(rowIndex, eventArgs) {
           alert("Click on row instance: " + eventArgs.get_itemIndexHierarchical());
           var e = window.event;
           var sourceElement;
           alert(sourceElement);
           if (e.srcElement) {
               sourceElement = e.srcElement;
               alert("sourceElement");
           }
           else if (e.target) {
           sourceElement = e.target;
           alert("target");
           }

       alert("About to check ROw Index");
       if (rowIndex != null) {

           alert("Checked ROw Index");
           inputField = grid.MasterTableView.Rows[rowIndex].Control.getElementsByTagName("INPUT")[0];
           alert(inputField);
           selvalue = sourceElement.value;
           alert(selvalue);
           if (inputField != null) {
               alert("About to show it");
               var popuppage = "userroleselect.aspx" + "?sel=" + selvalue + "&avail=" + inputField.value;
               alert("Shown it!");
               window.radopen(popuppage, "UserRoleDialog");
           }
           else {
               alert("Did Not Make it");
           }
       }
   }

请注意 eventArgs 参数,还请注意变量 e 现在已在函数中定义。

【讨论】:

  • 对不起,这是我的错字。即使我的警报框都没有出现,问题似乎出在 inputField = grid.MasterTableView.Rows[rowIndex].Control.getElementsByTagName("INPUT")[0];
  • 第一个问题是您的警报框应该出现。我会开始注释掉不必要的代码,直到出现警告框。一旦它们出现,我会一次添加一行代码,然后在添加每一行后进行测试,直到确定问题的确切位置。
  • 我清除了所有代码,但仍然无法弹出窗口
  • 我使用来自telerik.com/help/aspnet-ajax/grid_onrowclick.html 的示例代码进行了快速测试,它运行良好。我需要查看您的“简单” RowClick 函数以了解发生了什么。连接 GridView 的 onrowclick 事件很简单,您应该能够毫无问题地获得警报。
  • @Allison,以上是我现在拥有的
猜你喜欢
  • 1970-01-01
  • 2011-01-31
  • 2011-09-10
  • 2011-08-17
  • 1970-01-01
  • 2010-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多