Search code examples
angularjsng-gridui-sref

ui-sref in ng-grid rowTemplate


I have already used ui-sref in cellTemplate

getIndexDynamicColumnDefs: (data) ->
  sref = "stage.one({action: 'edit', id: {{row.getProperty('id')}}})"
  return [
    {field:'workable.user',displayName: 'Requesting User',cellFilter: 'camelize'}
    {field:'workable.requested_by',displayName: 'Requested_by',cellFilter: 'camelize'}
    {field:'workable.asset_type',displayName: 'Asset_type',cellFilter: 'camelize', cellTemplate: '<a ui-sref="' + sref+ '\"> ' + '{{row.getProperty(col.field)}}</a> '}
    {field:'workable.comments',displayName: 'Comments',cellFilter: 'camelize'}
    {field:'workable.created_at',displayName: 'Requested_on',cellFilter: "date:\'dd-MM-yyyy -- HH:mm \'" }]

and it worked.. Is it possible to use ui-sref in ng-grid rowTemplate? What i actually want is, I want to redirect to another page when i click a row in ng-grid.. But when I try to use it for rowTemplate i didn't know how to do that.. hope u will have some idea !!!!


Solution

  • In the code i have posted in the question, has the following lines

    {field:'workable.asset_type',displayName: 'Asset_type',cellFilter: 'camelize', cellTemplate: '<a ui-sref="' + sref+ '\"> ' + '{{row.getProperty(col.field)}}</a> '}
    

    It made the values within anchor tag as clickable..i want the entire division to be clickable..So i changed it to

    {field:'workable.asset_type',displayName: 'Asset_type',cellFilter: 'camelize', cellTemplate: '<div ui-sref="' + sref+ '\"> ' + '{{row.getProperty(col.field)}}</div> '}
    

    Made entire cell in the div to be clickable..To make entire row clickable,i gave the same cellTemplate to all the fields and finally got the entire row clickable