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

cell templates are not in the $templateCache

Open dtryon opened this issue 13 years ago • 1 comments

Hi, First off, ng-grid is awesome! It is saving us a lot of time so thanks to all who have contributed.

I'm wondering if not placing the cell templates in $templateCache is intentional. I see that some of the grid-level templates are cached:

self.initTemplates = function() { var templates = ['rowTemplate', 'aggregateTemplate', 'headerRowTemplate', 'checkboxCellTemplate', 'checkboxHeaderTemplate', 'menuTemplate', 'footerTemplate'];

    var promises = [];
    angular.forEach(templates, function(template) {
        promises.push( self.getTemplate(template) );
    });

    return $q.all(promises);
};

But, the cell templates (if referenced by path 'template.html') are retrieved from the server every time:

if (colDef.cellTemplate && !TEMPLATE_REGEXP.test(colDef.cellTemplate)) {
    self.cellTemplate = $.ajax({
        type: "GET",
        url: colDef.cellTemplate,
        async: false
    }).responseText;
}

This seems a bit backwards to me, because the cell templates are going to be used most often. Maybe, I'm missing the place where they are cached.

Is there any recommendation here? I'm considering writing a grunt task on my project to inject the content of the template files (html) back into the grid configuration controllers.

dtryon avatar Aug 13 '13 14:08 dtryon

Just saw issue #422. That was the background I was looking for. ;)

dtryon avatar Aug 13 '13 14:08 dtryon