2011-12-02 59 views
0

您好我在jqGrid中使用自定義格式化程序,它將鏈接和類添加到列。 我將調用的類名是'iframe',它將使用jquery colorbox設置我自己的對話框。 我在firebug中看到列名稱的類被設置爲'iframe',但是當我點擊它時,對話框沒有工作。我做錯了嗎?在列jqgrid中的類不工作

<script type="text/javascript" language="javascript"> 
jQuery(document).ready(function() { 
$(".iframe").colorbox({ iframe: true, width: "40%", height: "80%", onClosed:function(){ location.reload(true); } }); 

jQuery("#MyDynamicGrid").jqGrid({ 
     url: '/RepositoryRole/DynamicGridData/', 
     mtype: 'POST', 
     datatype: 'json', 
     colModel: [     
      { name: 'Name', index: 'Name', width: 0, align: 'left', searchoptions: { sopt: ['cn', 'eq', 'ne'] }, formatter: returnMyLink, editable: true, editrules: { required: true, edithidden: true }, hidden: false }, 
      { name: 'Description', index: 'Description', width: 80, align: 'left', searchoptions: { sopt: ['cn', 'eq', 'ne'] }, },     
     ], 

     colNames: ['Name', 'Description'], 
     pager: jQuery('#pager'), 
     rowNum: 5, 
     rowList: [5, 10, 20, 30], 
     sortname: 'Name', 
     sortorder: 'Desc', 
     viewrecords: true, 
     imgpath: '/Content/JqGridThemes/steel/images',    
     autowidth: true, 
     editurl: '/User/EditGrid/' 
    }); 

function returnMyLink(cellValue, options, rowdata, action) { 
    return '<a href="#" class="iframe">' + cellValue + '</a> '; 
}}); 

由於

回答

0

我認爲顏色框沒有被附接至其的jqGrid從加載元件。您可以使用gridComplete爲重新連接顏色框

jQuery("#MyDynamicGrid").jqGrid({ 
     url: '/RepositoryRole/DynamicGridData/', 
     mtype: 'POST', 
     datatype: 'json', 
     colModel: [     
      { name: 'Name', index: 'Name', width: 0, align: 'left', searchoptions: { sopt: ['cn', 'eq', 'ne'] }, formatter: returnMyLink, editable: true, editrules: { required: true, edithidden: true }, hidden: false }, 
      { name: 'Description', index: 'Description', width: 80, align: 'left', searchoptions: { sopt: ['cn', 'eq', 'ne'] }, },     
     ], 

     colNames: ['Name', 'Description'], 
     pager: jQuery('#pager'), 
     rowNum: 5, 
     rowList: [5, 10, 20, 30], 
     sortname: 'Name', 
     sortorder: 'Desc', 
     viewrecords: true, 
     imgpath: '/Content/JqGridThemes/steel/images',    
     autowidth: true, 
     editurl: '/User/EditGrid/', 
     gridComplete: function(){ 
     $(".iframe").colorbox({ iframe: true, width: "40%", height: "80%",  onClosed:function(){ location.reload(true); } } 
     } 
    }); 
+0

嗯沒錯,看來我要裝網格,直到完成之前我有打電話給另一個庫。謝謝 – Rivera