2016-11-17 47 views
0

這裏是ColModel:我想在link..I的點擊編輯對話框已附上代碼

{name: "FirstName", index: "FirstName", width: 100, sortable: true,  editable:true, formatter: GetRow}    

function GetRow(cellvalue, options, rowObject) { 
    return "<a href='#' class='GetLink'>" + cellvalue + "</a>"; 
} 
$('.GetLink').click(function (rowid) { 
    var row = $('#grid').jqGrid('getGridParam', 'selrow'); 
    $('#grid').jqGrid('editGridRow', row, { recreateForm: true, closeAfterEdit: true, closeOnEscape: true, reloadAfterSubmit: false }); 
}); 

回答

0

您當前的代碼有一些缺點。我會建議你使用formatter: "actions"的選項formatoptions: { editformbutton: true },而不是自定義格式創建編輯/刪除按鈕(見the old documentation,它描述了格式的選項,例如delbutton: false,其中刪除刪除按鈕)網格的每排。 The old answer描述了更詳細的方法,並提供了the demo,它演示了formatter: "actions"的用法。

如果你這樣做喜歡使用自定義的格式,那麼你可以使用<span>代替<a>

return "<span class='GetLink'>" + cellvalue + "</span>"; 

其中

.GetLink { text-decoration: underline; cursor: pointer; } 

而是使用$('.GetLink').click的,其註冊單獨點擊 - 對於每個hiperlink處理程序,我建議您在網格上使用一個點擊處理程序。 jqGrid註冊已經是這樣的點擊處理程序,並允許使用您的自定義操作beforeSelectRow回調。它節省了網絡瀏覽器的內存,並允許綁定一次,而不必在每次重新加載網格後重新應用綁定。有關更多詳情,請參閱the answer

其他答案可能對您有幫助:this onethis one

+0

@Oleg ...感謝您的建議和時間......當編輯對話框打開,我得到我修改爲標有鏈接「的 Cellvalue小區名稱還有一個問題是,「; 你能不能給一個解決方案在編輯對話框 – Supreeth

+0

@Supreeth只得到單元格的值:我不知道,我明白你的意思,但我猜你使用'編輯:列TRUE'與自定義格式。通常,人們永遠不需要編輯包含鏈接的列。您應該刪除'editable:true'或使用'editable:false'。通常在列中使用屬性'sortable:false,search:false,editable:false,viewable:false,hidedlg:true',它具有自定義格式化程序。 – Oleg

+0

@Supreeth:如果你確實需要編輯鏈接裏面的文本,那麼你應該在列中提供** unformatter **('unformat'回調)。請參閱[文檔](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter#unformatting)。 unformatter從自定義格式化單元格中獲取*可編輯部分*。 – Oleg

相關問題