khan4019 / tree-grid-directive

Need one or more maintainer for this! comment or email me if you are interested
http://khan4019.github.io/tree-grid-directive/test/treeGrid.html
347 stars 183 forks source link

Override expanding_property cellTemplate #143

Closed LTroya closed 7 years ago

LTroya commented 7 years ago

I am trying to overrideexpanding_property cellTemplate property but it is not working. Also I want to add a custom function to it, but it is not working.

This is my template

vm.expanding_property = {
    field: "descripcion",
    displayName: "Descripción",
    sortable: true,
    filterable: true,
    cellTemplate: "<strong>{{ cellTemplateScope.getType() }}</strong><span>{{row.branch[expandingProperty.field]}}</span>",
    cellTemplateScope: {
        getType: function () {
            return 'Some test';
        }
    }
};
torsten-sauer commented 7 years ago

Could you please provide the code where your tree-grid is defined inside your template? Maybe there's something wrong - this code looks like it should do what you expect.

Maybe you can also provide a plunker (or something equivalent) to check whats wrong.

LTroya commented 7 years ago

I don't using a template, only the default one.

This is the html

<tree-grid tree-data="ctrl.tree"
        col-defs="ctrl.col_defs"
        expand-on="ctrl.expanding_property"></tree-grid>

col_defs

vm.col_defs = [
    {
        field: "clave",
        displayName: "Clave",
        sortable: true,
        filterable: true
    }
];

That's the weird part. I see into the directive this code

<span ng-if=\"expandingProperty.cellTemplate\" class=\"indented tree-label\" " +
                "ng-click=\"on_user_click(row.branch)\" compile=\"expandingProperty.cellTemplate\"></span>

So this should work without problem.

torsten-sauer commented 7 years ago

Yeah, I meant your HTML where the tree is defined.

First I think the cellTemplate needs to be "one HTML element", you have two. Try to wrap the whole thing inside a div or a span. Could you please test this? If this is not working for you, I ask you to provide a simple Plunker where we can debug further.

Second: the cellTemplateScope is currently not working inside the expandingProperty (as stated in the docs, didn't try to use it before):

expanding_property: this is the property of the objects in tree_data where you want to put the ability to expand and collapse. This accepts an array of the same format as col_defs, allowing for sorting & filtering on the expanding field. This now includes the ability to provide a cellTemplate (but not a cellTemplateScope).

LTroya commented 7 years ago

Oh, it works as you say.

Thanks for your help and your explanation.