Demo - Auto-Size Rows

by Manish Gupta

HTML

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.filter.min.js"></script>
<div class="container">
  <div id="theGrid"></div>
</div>

CSS

.wj-flexgrid {
  max-height: 300px;
}

.wj-flexgrid .wj-marker {
  width: 1000px !important;
  height:5px;
  background-color:orange !important;
}

.wj-flexgrid [wj-part="rh"] {
  overflow: visible !important;
}

JavaScript

onload = function() {

  // create some random data
  var countries = 'Austria,Belgium,Canada,Denmark,Estonia,Finland,Germany,Hungary,Ireland,Japan,Korea,Lebanon,Mexico,Norway,Portugal,Qatar,Romania,Spain,Turkey,Ukraine,Venezuela,Zaire'.split(',');
  var data = [];
  for (var i = 0; i < 100; i++) {
    data.push({
    	id: i,
      countries: getCountries(),
      sales: Math.random() * 10000,
      expenses: Math.random() * 5000
    });
  }
  function getCountries() {
  	var c = [];
    var cnt = Math.round(Math.random() * 8) + 1;
    var start = Math.round(Math.random() * countries.length);
    for (var i = 0; i < cnt; i++) {
    	c.push(countries[(i + start) % countries.length]);
    }
    return c.join(', ');
  }

  // show the data in a grid with fixed height
  var theGrid = new wijmo.grid.FlexGrid('#theGrid', {
  	autoGenerateColumns: false,
    allowDragging: wijmo.grid.AllowDragging.Both,
    columns: [
    	{ binding: 'id', header: 'ID', width: 60, isReadOnly: true },
    	{ binding: 'countries', header: 'Countries', width: '*', wordWrap: true },
    	{ binding: 'sales', header: 'Sales' },
    	{ binding: 'expenses', header: 'Expenses' }
    ],
    itemsSource: data,
    selectionMode:'Row',
    itemFormatter:function(panel,r,c,cell){
    	if(panel.cellType == 1 && !panel.grid.editRange){
      	cell.draggable=true;
      }
    }
  });
  theGrid.hostElement.addEventListener("dragstart",function(e){
  				if(theGrid.hitTest(e).cellType==1){
            e.dataTransfer.effectAllowed="copy";
            e.dataTransfer.setData("text","");
          	_createImage(theGrid);
          }
  });
  theGrid.hostElement.addEventListener("dragover",function(e){
  	var ht=theGrid.hitTest(e);
    if(ht.cellType==1){
      e.dataTransfer.effectAllowed="copy";
      e.preventDefault();
    	_moveImage(theGrid,theGrid.hitTest(e));
    }
    
  });
  theGrid.hostElement.addEventListener("drop",function(e){
  var ht=theGrid.hitTest(e);
    if(ht.cellType==1){
 ...