2016-10-17 3 views
0

jQgrid를 생성하는 데 다음 코드가 있지만 select 아이콘을 클릭하면 select2 목록이 비어 있습니다. select2 코드를 제거하면 목록이 잘 채워집니다.jQuery select2를 jQgrid에 채우는 방법

jQuery를 1.11.3 있는 jqGrid 무료 4.13 내가 선택을 위해이 4.0.3 단지 다른 파일이 불필요한 될 것 같다 CSS

<table id="csstsoservicebulletinassignment"></table> 
<div id="csstsoservicebulletinassignmentpager"></div> 


<script type="text/javascript"> 
//var serialnumbervalidation = false; 
$(document).ready(function(){  
    var selID = ""; 
    var temp = ""; 
    var sourcevalue = ""; 
    var requestedchangelink = ""; 
    $("#csstsoservicebulletinassignment").jqGrid({ 
    url:'/QMSWebApp/CSSTSOControllerServlet?lifecycle=loadservicebulletinassignmentbodysection', 
    editurl:'/QMSWebApp/CSSTSOControllerServlet?lifecycle=editservicebulletinassignmentbodysection', 
    datatype: "json", 
    height: "auto", 
    colNames:['Index#','CO#','iService Bulletin#','Service Bulletin#'], 
    colModel:[ 
     {name:'id', index:'id', width:60, hidden: true, editable: true, editoptions:{ readonly:'readonly'}, editrules:{edithidden:true}, formoptions:{rowpos:1, colpos:1,label:"Index#:"}}, 
     {name:'cono', index:'cono', width:60, hidden: true, editable: true, editrules:{edithidden:true}, formoptions:{rowpos:2, colpos:1,label:"CO#:"}}, 
     {name:'sbnoindx', index:'sbnoindx', width:60, hidden: true, editable: true, 
     editrules:{edithidden:true}, formoptions:{rowpos:3, colpos:1,label:"Service Bulletin#:"}, 
      edittype: "select", 
      editoptions: { dataUrl: '/QMSWebApp/CSSTSOControllerServlet?lifecycle=servicebulletinoptions', 
        selectFilled: function (options) { 
         $(options.elem).width(122).select2({ 
          dropdownCssClass: 'ui-widget ui-jqdialog', 
          //width: '100%' 
         }); 
      }}, 
      stype: "select", 
      searchoptions: { dataUrl: '/QMSWebApp/CSSTSOControllerServlet?lifecycle=servicebulletinoptions', 
       selectFilled: function (options) { 
         $(options.elem).width(122).select2({ 
          dropdownCssClass: 'ui-widget ui-jqdialog', 
          //width: '100%' 
         });  
      } 
     }}, 
     {name:'sbnolink', index:'sbnolink', width:500, hidden: false}, 
     ], 
     onSelectRow: oSelect, 
     rowNum:10, 
     rowList:[10,15,20,25,30], 
     loadonce: true, 
     pager: '#csstsoservicebulletinassignmentpager', 
     viewrecords: true, 
     gridview: true, 
     loadComplete: lComplete, 
     caption:"Service Bulletin Assignment" 

    }); 
    $("#csstsoservicebulletinassignment").jqGrid('navGrid','#csstsoservicebulletinassignmentpager', 
     {edit:false,add:true,del:true,search:true,view:false, 
     beforeRefresh: function(){ 
      $("#csstsoservicebulletinassignment").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid'); 
      }}, 
     {url:'/QMSWebApp/CSSTSOControllerServlet?lifecycle=editservicebulletinassignmentbodysection', 
     recreateForm: true, 
     width: 400, 
     zIndex: 500992, 
     viewPagerButtons: false, 
     beforeShowForm: bsEditForm, 
     afterShowForm: asEditForm, 
     checkOnSubmit: false, 
     afterSubmit: asubEditForm, 
     }, 
     {recreateForm: true, 
     zIndex: 500992, 
     beforeInitData: biAddForm, 
     beforeShowForm: bsAddForm, 
     afterShowForm: asAddForm, 
     beforeSubmit: bsubAddForm, 
     checkOnSubmit: false, 
     afterSubmit: asubAddForm, 
     afterComplete: afComp, 
     width: 400, 
     }, 
     {zIndex: 500992}, 
     {zIndex: 500992}, 
     {recreateForm: true, 
     zIndex: 500992, 
     width: 400, 
     viewPagerButtons: false 
     } 
    ); 

    function lComplete(data){ 

     $('.viewservicebulletincontext').on("click", function(){ 

      var servicebulletinno = this.getAttribute("data-servicebulletin"); 
      progress(); 
      setTimeout(function(){ 
       $('.miscdisplay2').load("/QMSWebApp/CSSTSOControllerServlet", 
       {lifecycle:"viewservicebulletincontext",servicebulletinno:servicebulletinno}); 
       $('.miscdisplay2').show("slide", { direction: "right" }, 1000);  
      },100); 

     }); 


     hideProgressDisplay();   
    }; 
    function oSelect(id){ 
     //$("#csstsoservicebulletinassignment").setColProp('twotype', { editoptions: { dataUrl: '/QMSWebApp/CSSTSOControllerServlet?lifecycle=twotypeoptions'}});  

    }; 

    function bsEditForm(formId){ 

     $('#tr_id', formId).hide(); 
     $('#tr_cono', formId).hide(); 
     $('#tr_sbnolink', formId).hide(); 

    } 
    function asEditForm(formId){ 


    } 
    function asubEditForm(response, postdata){ 
     return [true,"Ok"]; 

    } 
    function biAddForm(formId){ 
     //$("#csstsoservicebulletinassignment").setColProp('sbnoindx', { editoptions: { dataUrl: '/QMSWebApp/CSSTSOControllerServlet?lifecycle=servicebulletinoptions', selectFilled: function(options){$(options.elem).select2({dropdownCssClass: "ui-widget ui-jqdialog",width: "100%"});}}});   

    }; 
    function bsAddForm(formId){ 

     $('#tr_id', formId).hide(); 
     $('#tr_cono', formId).hide(); 
     $('#tr_sbnolink', formId).hide(); 

    } 

    function asAddForm(formId){ 

    } 

    function bsubAddForm(postdata, formid){ 
         return [true,"Ok"]; 
     //} 

    } 
    function afComp(response,postdata,formId){ 


    } 
    function asubAddForm(response, postdata){ 

     var res = $.parseJSON(response.responseText); 
     if(res){ 
      if(!res.errorCode){ 

       return [false,res.message]; 

      } 
      else{ 

       return [true,"Ok"]; 
      } 
     } 
     else{ 

      return [true,"Ok"]; 
     } 

    } 

    $('.csstsoservicebulletinassignmentFormClose').on("click", function(){ 

     //$('.miscdisplay2').hide("slide", { direction: "right" }, 1000); 
     $('.miscdisplay').hide("slide", { direction: "right" }, 1000); 

    });  

}); 

+0

[답변] (http : //) 용으로 만든 [데모] (http://www.ok-soft-gmbh.com/jqGrid/OK/formEditOnDoubleClick-jqueryui-fa3.htm)를보십시오. stackoverflow.com/a/37876387/315935). 그것은 select2와 함께 무료 jqGrid를 사용하며 양식 및 인라인 편집과 함께 작동합니다. 게시 한 코드에는 다른 많은 것들이 포함되어 있습니다. 문제를 재현하는 데모를 보지 않고도 정확히 어떤 문제인지 결정하는 것은 어렵습니다. 아마도 내 데모와 코드를 비교하면 문제를 볼 수 있습니다. – Oleg

+0

어떤 이유로 데모가 열리지 않습니다. –

+0

@Oleg 방금 추가 양식을 이동했는데 목록이 양식 아래에 표시되었습니다. 따라서 Z- 색인 문제 여야합니다. select2 목록을 맨 위에 올리는 방법이 있습니까? 추가 양식의 Z- 색인은 500992입니다. –

답변

1

사용 zIndex: 500992 옵션입니다 (전체) 선택 2 . 데모가 작동하도록하려면 제거 만하면됩니다. 당신이 정말로 추가/편집 대화 상자에 대한 z-index: 500992이 필요한 경우 다음 (예를 들어, 사용 .select2-dropdown { z-index: 500993; }에 의해)을 z-index 선택 2의 드롭 다운 메뉴에 사용 .select2-dropdown의 증가가, the answer

생성 the demo와 비교. 드롭 다운 메뉴에 맞춤 클래스를 추가하는 옵션 인 dropdownCssClass: 'ui-widget ui-jqdialog'을 이미 사용하고 있습니다. 당신은

dropdownCssClass: "ui-widget ui-jqdialog mycustomclass" 

에 옵션을 수정하고 또 하나의 CSS 규칙 추가 :

.mycustomclass { z-index: 500993; } 

그것은 당신의 문제를 해결해야합니다.

+0

이것은 수정되었습니다. 정말 고맙습니다. –

+0

@SteveDyke : 천만에! 문제가 해결되면 대답을 [받아 들여야]합니다 (http://meta.stackexchange.com/a/5235/147495). 당신은 당신이 도움이되고 다른 독자를 추천할만한 stackoverflow에 대해 어떤 대답이나 질문에 투표 할 권한이 있습니다. 하루에 약 30 개의 질문과 답변 **을 투표 할 수 있습니다 ** (자세한 내용은 [here] (http://meta.stackexchange.com/a/5213/147495) 참조). 검색 엔진이 투표 카운터를 사용하기 때문에 어떤 방식 으로든 찾을 수있는 stackoverflow의 좋은 (유용한) 정보를 투표하는 것이 좋습니다. – Oleg

+0

@Oleg 선생님 제발 당신은이 질문을 들여다 볼 수 있습니다 http://stackoverflow.com/questions/40107837/define-ngclick-in-the-jqgrid – shv22