ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Row template example not working?

Open axschech opened this issue 12 years ago • 13 comments

http://ui-grid.info/docs/#/tutorial/4.1_custom_row_template

I can't seem to get this code to work in my project, and it looks like it's broken on the site too.

Is it wrapped in a $timeout function because of the $http.get? Why not use a promise instead?

Also, the table doesn't seem to render when you apply a custom row template.

axschech avatar Aug 06 '14 19:08 axschech

@c0bra sorry, I didn't know which place to post this. I hope this is actually a legitimate issue and not me being stupid!

axschech avatar Aug 06 '14 20:08 axschech

@axschech No worries; it is definitely a legitimate issue. Looks like the custom row template is being returned to uiGridRow, but it's being compiled weird. Looking at the DOM it has an ngRepeat comment for the columns but it's not being expanded. Not sure when this would have broken; it did work at one point.

$timeout() does return a promise. It's intended to just be a quick way of showing asynchronous row template usage.

c0bra avatar Aug 06 '14 20:08 c0bra

@c0bra I'm sorry I meant "why not use $resource" instead. This way you don't waste any time between since instead of waiting an arbitrary amount of seconds you would be waiting until the data was received and loaded.

edit: also thanks for the fix!

axschech avatar Aug 06 '14 20:08 axschech

@c0bra is there anyway to add an ng-click directive to the row using this method?

axschech avatar Aug 06 '14 21:08 axschech

Should be able to. Grid cells or row selection (once done) may capture click events though. What would you want to do with clicking?

c0bra avatar Aug 06 '14 21:08 c0bra

well eventually it will open a context menu (perhaps a roadmap feature?) but right now I'm just trying to get it to work.

I have a function in my controller:

$scope.theClick = function() {

console.logged("clicked");

}

and here is my template string: rowTemplate:

'<div style="background-color: aquamarine" ng-repeat="col in colContainer.renderedColumns track by col.colDef.name" ng-click="theClick()" class="ui-grid-cell" ui-grid-cell></div>'

Perhaps it's a scope issue? Is the cell / row outside of the scope of my controller?

axschech avatar Aug 06 '14 21:08 axschech

all grid scope is now isolate. You must use externalScopes attribute. See api docs http://ui-grid.info

swalters avatar Aug 06 '14 21:08 swalters

Would you mind giving me an example? The documentation isn't very clear.

Would it be something like externalScopes="theClick()" on the ui-grid div?

axschech avatar Aug 07 '14 15:08 axschech

ever solved this issue?

mikila85 avatar Feb 09 '15 11:02 mikila85

Have the examples been updated? I can't get the row templates to show anything at all. Using the "default"

<div ng-style="{\'cursor\': row.cursor, \'z-index\': col.zIndex() }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell {{col.cellClass}}" ng-cell></div>

FlavorScape avatar Feb 26 '16 17:02 FlavorScape

@FlavorScape @mikila85 are you still having an issue where where you are unable to set a custom rowTemplate?

ackimwilliams avatar Mar 04 '16 20:03 ackimwilliams

I was able to, but had to reference the src for the templates. It's just that the example code no longer works, so I guess it's not a huge deal. But, the examples seem to exist in a few places, so it's easy to miss this tidbit.

FlavorScape avatar Mar 04 '16 20:03 FlavorScape

I am trying to use the default example given at https://github.com/angular-ui/ui-grid/wiki/templating for the row template. When I put that template as grid row template, I get nothing displayed. I can see the commented ng-repeat inside row for 'col in renderedColumns' as @c0bra commented above long back. I am using angular "1.5.6" and ui-grid "3.2.9". Has this been fixed?

ksgupta-adobe avatar Dec 13 '16 04:12 ksgupta-adobe