2

I am using Smart-table to show reports to the user with Angular js.

Now,I want to customize table header and want a colspan in smart table 's header.

Does anyone know about this?Is it possible? Please share example,plunker if anyone have achieved this

2
  • Why don't you share with us an example plunkr, and we can help you achieve what you want...? Commented Apr 10, 2014 at 13:25
  • @Nix plnkr.co/edit/xsJs8m?p=preview Above plunkr is already created by some one.In above example I want one column called "NAME" which containts colspan=2 and in those cell First Name and Last Name will be stored Commented Apr 16, 2014 at 8:03

2 Answers 2

1

You can have whatever template you want in cellTemplate attr, where I have concatenated both first name and last name.

Like I have used,

 scope.columnCollection = [
                { label: 'Name', map: 'FirstName', validationAttrs: 'required', validationMsgs: '<span class="error" ng-show="smartTableValidForm.FirstName.$error.required">Required!</span>',cellTemplate:'<div class="name"><span>{{dataRow.FirstName +" "+dataRow.LastName}}</span><div>'}, //have whatever template you want and your custom css
                //{ label: 'Last Name', map: 'LastName' },
                { label: 'User Name', map: 'UserName', validationAttrs: 'required' },
                { label: 'Password', map: 'Password', noList: true, editType: 'password' },
                { label: 'Customer', map: 'CustId', optionsUrl: '/GetCusts', editType: 'radio' },
                { label: 'Role', map: 'RoleId', optionsUrl: '/GetRoles', editType: 'select', defaultTemplate: '<option value="" ng-hide="dataRow[column.map]">---</option>', validationAttrs: 'required', validationMsgs: '<span class="error" ng-show="smartTableValidForm.RoleId.$error.required">Required!</span>' }, // NOTE: small hack which enables defaultTemplate option :)
                { label: 'E-mail', editType: 'email', map: 'Email' },
                { label: 'Cell Phone', map: 'Mobilephone', noEdit: true, validationAttrs: 'required' },
                { label: 'Locked', map: 'IsLocked', cellTemplate: '<input disabled type="checkbox" name="{{column.map}}" ng-model="dataRow[column.map]">', editType: 'checkbox', noAdd: true }
            ];

In css you can have your custom Css.

Please have a look at this plunker

Hope this solves your problem :)

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

Comments

0

Based on the documentation you need to add something like this:

app.controller('basicsCtrl', ['$scope', function (scope) {
    scope.rowCollection = [
        {firstName: 'Laurent', lastName: 'Renard', birthDate: new Date('1987-05-21'), balance: 102, email: '[email protected]'},
        {firstName: 'Blandine', lastName: 'Faivre', birthDate: new Date('1987-04-25'), balance: -2323.22, email: '[email protected]'},
        {firstName: 'Francoise', lastName: 'Frere', birthDate: new Date('1955-08-27'), balance: 42343, email: '[email protected]'}
    ];

    scope.columnCollection = [
        {label: 'First Name', map: 'firstName'},
        {label: 'same same but different', map: 'firstName'},
        {label: 'Last Name', map: 'lastName'}
    ];
}]);

Your columnCollection will adjust the labels based on the mappings.

3 Comments

I tried with your suggestion.but not working. It will repeating the value because of firstName mapping
Share some of your code so we know where you are starting
plnkr.co/edit/xsJs8m?p=preview Above plunkr is already created by someone.As per your suggestion I have tried and changed LastName to FirstName in columnCollection scope variable. but Output is like it's repeating firstName column's value to lastName column because we have same value "FirstName" in LastName columns map attribute

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.