0

I am new to angular js. I have read this question before Conditional cell template in ui-grid angularjs and its absolutely worked for me, but I am just wondering how to display html like a button tag instead of text, because when I am trying to change it to html, it always display html as text

Thanks and sorry because of my bad english

js file

var columnDefs = [
    {
        field: 'action',
        displayName: label.action,
        width : 175,
        enableCellEdit: false,
        cellTemplate: '<div>{{grid.appScope.states.showMe(row.entity.j_code, row.entity.branch_cd)}}</div>',            
    }];

scope.gridOptions.columnDefs = comlumnDefs;
$scope.states = {
    showMe: function(j_code, branch_cd) {
        template = "<button class='btn-small btn-green btn-add'>Add</button>";
        if (j_code != "" && branch_cd != "") {
            template += "<button class='btn-small btn-green'>Copy</button>";
        }
        return template;
    }
};

html file

<div id="grid1" class="gridStyle" ui-grid="gridOptions" external-scopes="states" ui-grid-pinning ui-grid-resize-columns ui-grid-pagination ui-grid-edit ui-grid-row-edit ui-grid-cellnav ui-grid-selection ui-grid-exporter></div>
2
  • You should probably show your code if you want people to offer suggestions. Commented Jun 3, 2015 at 5:20
  • I have edited my post and the problem here is it always display as text, all I want is just display the button. Please help @KreepN Commented Jun 3, 2015 at 8:09

1 Answer 1

0

I do not know if you ve found the asnwer or not but there are others who visit to find an answer.

 .Columns(c =>
   {
    c.Add().DataField("give a name").CellTemplate("<input type=button>");
   }

you can add a checkbox or other functions into the type.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.