MrProgram MrProgram - 4 years ago 70
AngularJS Question

make first column always fixed and the rest compressed in table

I have a table where I wanna display the first column always on one row and the other ones to somehow press themselves together one the rest of the space.

I have tried to simulate a fixed width at 320 (for phone size)..

Here is my plunker:

Below you can see all the code and the CSS with it..

<!doctype html>
<html ng-app="plunker">

<link rel="stylesheet" href="" />
<script data-require="angular.js@*" data-semver="1.2.0" src=""></script>
<script src=""></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>

<div ng:controller="MainCtrl">

<table border="1" style="width: 320px;" class="table table-striped table-hover table-responsive table-bordered">
<thead style="font-weight: bold;">
<th ng-repeat="column in columnsTest" ng-if="column.checked" ng-bind=""></th>
<tr ng-repeat="row in rows">

<td ng-repeat="column in columnsTest" ng-if="column.checked">
<span class="glyphicon glyphicon-circle-arrow-right" ng-show=" === 'Value1'"></span>

<p>Visible Columns:</p>
<br />
<div class="cbxList" ng-repeat="column in columnsTest">
<input type="checkbox" ng-model="column.checked">{{}}


table {
table-layout: fixed;
width: 100%;
font-size: 10px;

td {
word-wrap: break-word;

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
$scope.columnsTest = [{
id: 'Value1',
checked: true
}, {
id: 'Value2',
checked: true
}, {
id: 'Value3',
checked: true

$scope.rows = [{
id: 1,
"Value1": 'Thisshouldbeonerow',
"Value2": 2013321,
"Value3": 2012352432423

$scope.columnToggled = function(column) {
$('[data-col-id="' + + '"]').each(function() {
var element = this;
if ($(element).hasClass('ng-hide')) {
} else {

function updateRow(row) {
for (var i = 0; i < $scope.rows.length; i++) {
if ($scope.rows[i].id === {
$scope.rows[i] = row;



Answer Source

Hi Check out this plunker

.fixed_headers {
  width: 750px;
  table-layout: fixed;....

checkout for further

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download