2017-04-13 64 views
0

最近我在我的角度項目中使用了jqwidgets即網格。在這裏,我只是把一個編輯放在每個單元格中,點擊它應該重定向到編輯屏幕。如何使用jquery的角度2中的點擊功能

我試圖在以下幾個方面:

案例1:

var Action = function (row, columnfield, value, defaulthtml, columnproperties) { 
    return '<button onClick="open()">EDIT</button>' 
} 

案例2:

var Action = function (row, columnfield, value, defaulthtml, columnproperties) { 
    return '<button (Click)="open()">EDIT</button>' 
} 

案例3:

var Action = function (row, columnfield, value, defaulthtml, columnproperties) { 
    return '<button routerLink="user/edit/value">EDIT</button>' 
} 

所有上述情況下失敗。誰能幫幫我嗎。謝謝。

我的組件,

var Action = function (row, columnfield, value, defaulthtml, columnproperties) { 
    return '<button>EDIT</button>' 
} 

this.columns = [ 
    { 
     text: 'S.No', columntype: 'textbox', filtertype: 'input', datafield: 'id', width: 50, cellsalign: 'center' 
    }, 
    { 
     text: 'FirstName', columntype: 'textbox', filtertype: 'input', datafield: 'first_name', width: 100 
    }, 
    { 
     text: 'LastName', columntype: 'textbox', filtertype: 'input', datafield: 'last_name', width: 100 
    }, 
    { 
     text: 'ServiceType', columntype: 'textbox', filtertype: 'input', datafield: 'servicetype', width: 50 
    }, 
    { 
     text: 'Gender', columntype: 'textbox', filtertype: 'input', datafield: 'gender', width: 50 
    }, 
    { 
     text: 'DateofBirth', columntype: 'textbox', filtertype: 'input', datafield: 'birthday', width: 100 
    }, 
    { 
     text: 'Location', columntype: 'textbox', filtertype: 'input', datafield: 'formatted_address', width: 215 
    }, 
    { 
     text: 'AdultContentPrivay', columntype: 'textbox', filtertype: 'input', datafield: 'display_adult_content', width: 100 
    }, 
    { 
     text: 'LoginType', columntype: 'textbox', filtertype: 'input', datafield: 'logintype', width: 100 
    }, 

    { 
     text: 'Groups', columntype: 'textbox', filtertype: 'input', datafield: 'groups_count', width: 100 
    }, 
    { 
     text: 'Events', columntype: 'textbox', datafield: 'events_count', width: 100 
    }, 
    { 
     text: 'Albums', columntype: 'textbox', datafield: 'albums_count', width: 100 
    }, 
    { 
     text: 'Photos', columntype: 'textbox', width: 100 
    }, 
    { 
     text: 'Actions', columntype: 'dropdownlist', cellsrenderer: Action, width: 100, filterable: false 
    }, 

    { 
     text: 'More', columntype: 'dropdownlist', cellsrenderer: More, width: 100, filterable: false 
    } 
]; 
+0

。走出這個jQuery世界。使用[**這**](https://www.primefaces.org/primeng/#/datatable)而不是 – Aravind

+0

嗨Aravind,這看起來好多了,並希望在角2創建此。 – MMR

+0

我沒有得到你。詳細說明你的問題 – Aravind

回答

0

當你有很多的插件在本地angular2爲什麼你去jQuery的嘗試

<a [routerLink]="['./SomewhereElse']">Edit</a> 
+0

HI Ramya,因爲這是在jQuery [routerLink]不起作用。 – MMR

+0

爲什麼路由器連接不工作?它是寫在一個角度的組件裏嗎? – RemyaJ