2017-04-13 4 views
0

Kürzlich habe ich jqwidgets i.e. Raster in meinem eckigen Projekt verwendet. Hier lege ich einfach eine Bearbeitungsstelle in jede Zelle, die angeklickt werden sollte, um auf Bearbeitungsbildschirm umzuleiten.Wie jquery auf Klick-Funktion in angular 2 verwenden

habe ich versucht, auf folgende Weise:

Fall 1:

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

Fall 2:

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

Fall 3:

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

Alle hier genannten Fällen fehlgeschlagen . Kann mir bitte jemand helfen. Vielen Dank.

Meine Komponente,

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

, wenn Sie eine Menge von Plugins in nativer angular2 haben, warum haben Sie für jQuery gehen. Komm aus dieser jQuery-Welt. Benutze [** this **] (https://www.primefaces.org/primeng/#/datatable) anstatt – Aravind

+0

Hi Aravind, das sieht ziemlich viel besser aus und will das in eckigen 2 erstellen. – MMR

+0

ich habe dich nicht bekommen. Erarbeiten Sie Ihre Frage – Aravind

Antwort

0

Versuchen

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

HI Ramya, da dies in jquery ist [routerLink] funktioniert nicht. – MMR

+0

Warum funktioniert der Router nicht? Es ist in einer eckigen Komponente geschrieben, richtig? – RemyaJ

Verwandte Themen