2012-12-10 129 views
0

我正在使用jquery對話框並在jquery對話框中顯示JqGrid。一切都工作得很好,但JqGrid正在顯示爲一個不可編輯的模式。所以我不能編輯對話框中的任何東西。JqGrid在jQuery對話框中顯示爲不可編輯的模式

即使我關閉並重新打開對話框,它仍然是一樣的,只是如果我刷新頁面就變得正常,直到整個對話框顯示爲不可編輯模式...

的代碼邏輯作品很好,很好..這似乎是一個用戶界面問題..請幫助我出來..無論如何,我張貼我的代碼下面供您參考..仔細查看,並幫助我解決問題..

This是我的aspx代碼:

<div> 
<span id="span_create" style="color: #88b807; margin-left: 839px; 
          margin-top: -12px; cursor: pointer; display: block">Create</span> 
</div> 
    <div id="Createdialog" style="display: none; overflow: hidden"> 
        <table id="table" style="border-spacing: 7px 7px; margin-left: 5px"> 
         <tr> 
          <td> 
           <span class="SubHeading" style="font-size: 10pt;">Private Space Name </span> 
          </td> 
          <td> 
           <asp:TextBox ID="txt_spacename" runat="server" /> 
          </td> 
         </tr> 

         <tr> 
          <td> 
           <span class="SubHeading" style="font-size: 10pt;">Users </span> 
          </td> 
          <td> 
           <asp:TextBox ID="txt_users" TextMode="MultiLine" runat="server" /> 
          </td> 
          <td> 
           <asp:Button ID="btn_addusers" Text="Add" Style="margin-left: 0px;" runat="server" /> 
          </td> 
         </tr> 
         <tr> 
          <td> 
           <table id="users_grid"> 
           </table> 
          </td> 
         </tr> 
        </table> 
        <input type="button" id="Btn_Submit" value="Create" style="margin-left: 280px; margin-top: 8px;" 
         runat="server" /> 
       </div> 

這是我的Js代碼:

$("#Createdialog").dialog({ 
       autoOpen: false, 
       title: 'Create Private space', 
       modal: true, 
       position: 'center', 
       width: 900 

      }); 

      $('#span_create').click(function() { 
       $("#Createdialog").find('input:text, textarea').val(''); 
       $('#Createdialog').dialog('open'); 
       return false; 
      }); 

$('#btn_addusers').click(function() { 

     $("#users_grid").jqGrid({ 

      colNames: ['User_ID', 'Name', 'Email_Id'], 
      colModel: [{ name: 'User_ID', index: 'User ID', width: 130, editable: false, sortable: false }, 
      { name: 'Name', index: 'Name', width: 350, editable: false, sortable: false }, 
      { name: 'Email_Id', index: 'Email Id', width: 350, editable: false, sortable: false}], 

      width: 400, 
      height: 'auto', 
      multiselect: true, 
      modal: false 

     }); 


     var UserID = $('#Header1_txt_users').val(); 
     var datapost = {}; 


     datapost.UserId = UserID; 
     var postJSONData = JSON.stringify({ 'postdata': JSON.stringify(datapost) }); 


     $.ajax({ 
      type: 'POST', 
      data: postJSONData, 
      url: 'PrivateSpaceService.asmx/GetUserDetails', 
      dataType: 'json', 
      async: false, 
      contentType: 'application/json; charset=utf-8', 
      success: function success(response) { 

       UserArr = response.d; 

      }, 
      error: function failure(response) { 
       alert('failed'); 
      } 
     }); 

     var mydata; 


     for (var i = 0; i < UserArr.length; i++) { 


      mydata = {}; 


      mydata.User_ID = UserArr[i].UserId; 
      mydata.Name = UserArr[i].UserName; 
      mydata.Email_Id = UserArr[i].EmailId; 

      $("#users_grid").jqGrid('addRowData', 'GridData_Row_' + (i + 1), mydata); 


     } 
     return false; 


    }); 
+1

對不起,但很難理解你有什麼問題。你寫的例子「但JqGrid被顯示爲一個不可編輯的模式」。你在每一列中使用'editable:false'屬性。哪些編輯你有什麼?你的意思是哪個「可編輯模式」?此外,通過使用'addRowData',以非常低效的方式填充網格體。如果你需要爲每個Ajax從服務器加載的數據填充網格,你應該直接使用jqGrid,並使用一些jqGrid選項,比如'jsonReader',它對應於從服務器返回的數據格式。 – Oleg

+0

@Oleg一旦我單擊jQuery對話框中的「btn_addusers」,將顯示jqgrid ..但它顯示爲對話框(即)內的模態,就像在頁面中的模態對話框... – Xavier

+0

對不起,但我不明白你的意思。 jqGrid只是您創建的對話框中的一個可視元素。它如何可以是「模態」?我仍然不明白你的意思是什麼樣的編輯。 – Oleg

回答

0

可能是z-index問題。下面是一個示例代碼的示例代碼(http://jsfiddle.net/c3BPP/),它有一個更大的z-index,它可以工作。與Z指數像100它不可編輯

試試吧。

+0

對話框對我來說工作正常..只有在顯示JQgrid後,我才面對問題 – Xavier