2015-12-28 30 views
0

當我從列表中選擇(點擊)所需記錄時,如何從列表視圖移動到編輯視圖?從視圖(URL)移動到另一個onclick動作

我可以做我想要的,當我點擊一個特定的按鈕,因爲它是在下面的代碼清除,但我想要刪除此按鈕,並用點擊操作取代它。

誰能幫幫我嗎?

{ title: '@Resources.General.View', template: '<a href="ViewIndividuals?individualsNo=#=IN_InNo#" class="btn btn-default btn-bordered" ><i class="fa fa-eye"></i></a>' }, 

這是我的代碼: var grid = $("#MyGrid").kendoGrid({ dataSource: ds, // inject common kendo settings @Html.Partial("_kendo_JS_Setting") columns: [ { field: "IN_InNo", width: 100, title: '@WebHelper.LocalResources(this, "IndividualsNumber")' }, { field: "IN_Name", width: 100, title: '@Resources.General.Name' }, { field: "IN_Address1", width: 100, title: '@WebHelper.LocalResources(this, "IN_Address1")' }, { field: "IN_Mobile1", width: 100, title: '@WebHelper.LocalResources(this, "IN_Mobile1")' }, { field: "IN_CreationDate", width: 100, title: '@Resources.General.CreationDate', template: "#= kendo.toString(kendo.parseDate(IN_CreationDate, 'yyyy-MM-dd'), 'MM/dd/yyyy') #", groupable: false }, { field: "IN_CreatedBy.FullName", width: 100, title: '@Resources.General.CreatedBy' }, @{ field: "ModificationDate", width: 100, title: '@Resources.General.LastUpdate' }, { field: "ModifiedBy.FullName", width: 100, title: '@Resources.General.ModifiedBy' },@ { title: '@Resources.General.View', template: '' }, @{ title: '@Resources.General.Edit', template: '' }, { title: '@Resources.General.Delete', template: '' }, { title: '@WebHelper.LocalResources(this, "Attachments")', template: '' },@ ] }).data("kendoGrid"); // add tooltip

+0

這是我的代碼: {title:'@Resources.General.View',模板:''}, – Moro

+0

請修改原來的文章在評論中增加相關信息。 –

回答

0

雖然,相關的代碼失蹤,我只能猜測你想實現什麼,我要做的就是用數據屬性設置的HTML在您要傳遞編輯視圖鏈接的行上,然後爲該行上的點擊添加單擊事件處理程序。

<tr class="item-row" data-href="@Url.Action("ViewIndividuals","ControllerName", new { individualsNo= individualsNo})"> 
    <td>x</td> 
    <td>xx</td> 
</tr> 

下一步是創建jQuery的事件處理程序:

$('.item-row').click(function(){ 
    var url = $(this).data('href'); 
    window.location = url; 
}); 

當然,動作可被綁定到任何元件,不僅錶行。只需要注意添加data-href屬性的位置。

此外,數據屬性可以根據你的意願命名,例如, data-link,data-url,data-action,...

+0

沒關係,但是我的記錄沒有插入表格中,因爲我使用的是類似於此代碼的kendo工具: – Moro

+0

@Moro無論它是表格,div還是任何其他元素,都無關緊要。其背後的想法是傳遞數據(在這種情況下是動作的URL),並使用jQuery進行點擊。 –

相關問題