Custom Viewport Template failing to load

95 views
Skip to first unread message

mportugal

unread,
Aug 14, 2016, 10:51:08 PM8/14/16
to UI-Grid Support

I’ve successfully added several custom templates to ui-grid in the past. Header template, cell template, header cell template have been no problem.

However I’ve been trying to add a custom viewport template to ui-grid with no success.

I tried adding the template:

  • Exactly as the tutorial
  • Using the method that has worked successfully with other templates.

I’ve also searched for issues covering this with no success.

Here’s a custom header template successfully added:

https://plnkr.co/edit/Vh4uEX5Gksk0kHkVV7Yk?p=preview

Then here’s a custom viewport template failing to load using the same method:

https://plnkr.co/edit/50dmzHwdhZNWj0tzR7ux?p=preview

I’m using ui-grid 3.1.1

  • Is it possible to add a custom viewport template?
  • If so, what am I doing wrong?

mportugal

unread,
Aug 14, 2016, 10:53:06 PM8/14/16
to UI-Grid Support
As far as I can tell from comparing the UI-Grid Header code and the ui-grid-viewport code, it is not possible to modify the viewport template.


egor.ko...@da-14.com

unread,
Aug 9, 2017, 5:55:43 AM8/9/17
to UI-Grid Support
If still relevant...
You can replace original template with your own.

// Replace default ui-grid template
const oldTemplate = $templateCache.get('ui-grid/uiGridViewport');
$templateCache
.remove('ui-grid/uiGridViewport');
$templateCache
.put('ui-grid/uiGridViewport', 'YOUR CUSTOM TEMPLATE GOES HERE');


$scope
.$on('$destroy', () => {
   
// Restore default ui-grid template
    $templateCache
.remove('ui-grid/uiGridViewport');
    $templateCache
.put('ui-grid/uiGridViewport', oldTemplate);
});

Reply all
Reply to author
Forward
0 new messages