2011-03-01 52 views
0

需要一些幫助來找出這一個請。我想添加一個On RowClick事件處理程序到我的RadGrid,以處理RadGrid Editform模式中RadComboBox的選擇。我想要做的是,當用戶從組合框中進行選擇時,顯示一個RadWindow以允許用戶在RadGrid Editform的文本框中顯示其他選擇。到目前爲止,我有什麼顯示什麼都沒有,甚至沒有alertboxesRadGrid RadComboBox客戶端彈出幫助

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> 
+0

你如何附加RowClick事件? – 2011-03-06 15:44:26

回答

0

調試你的js代碼,看看哪些部分呢得到處理併發生錯誤。這可以幫助您追蹤哪些問題。

+0

通過在代碼中添加警報進行調試並沒有減少太多,因爲它似乎偶爾運行,而不是如預期的那樣。 – Kobojunkie 2011-03-07 19:57:39

0

看看下面的一行:

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現在在函數中定義。

+0

對不起,這是我的一個錯字。即使沒有我的警報boixes出現,問題似乎與行inputField = grid.MasterTableView.Rows [rowIndex] .Control.getElementsByTagName(「INPUT」)[0]; – Kobojunkie 2011-03-07 20:56:16

+0

第一個問題是您的警報框應該出現。我會開始評論不必要的代碼,直到出現警告框。一旦出現,我會一次添加一行代碼,然後在添加每行之後進行測試,直到確定問題的確切位置。 – 2011-03-07 21:09:19

+0

我清除了所有的代碼,並且仍然無法彈出 – Kobojunkie 2011-03-07 22:57:20