2013-05-29 61 views
1

我有一個的WebGrid,因爲我的專欄是動態的,我沒有定義在任何的WebGrid列將在下文如何打開一個彈出窗口,MVC的WebGrid,動態列

@grid.GetHtml(tableStyle: "webgrid", 
       headerStyle: "webgrid-header", 
       footerStyle: "webgrid-footer", 
       alternatingRowStyle: "webgrid-alternating-row", 
       selectedRowStyle: "webgrid-selected-row", 
       rowStyle: "webgrid-row-style" 
      ) 

說。

我的問題是,我如何鏈接特定列打開彈出?

請讓我知道。

回答

0

添加一個類到項目(一個achor標籤?),當你想在點擊時顯示一個彈出窗口。所以,你的HTML可以被渲染爲類似

<a href="user/details/12" class="aPopup">View details</a> 

現在擁有jQuery代碼有點聽鏈接的點擊事件,並顯示一個彈出。您可以直接致電window.open方法,該方法在新窗口中打開頁面或使用插件顯示模型彈出窗口。

$(function(){ 
    $("a.aPopup").click(function(e){ 
    e.preventDefault(); 

    var popupUrl=$(this).attr("href"); 

    //code to show popup here 
    //window.open or model popup plugin call 

    });  
}); 

有一些插件顯示模型彈出。退房jQuery UI dialog

+0

謝謝,這應該解決我的問題 –

+0

嗨Shyju,當我給href它不呈現相同的HTML,而是它顯示View Extra details。我怎樣才能讓這看起來像超鏈接的HTML。我正在從我的SQL查詢做到這一點。 –

+0

你的意思是由超鏈接的HTML?那是不是一個「標籤」? – Shyju

相關問題