How to get multiline text in cells in Datatable?

edited February 2014 in Technical questions

Is there any option to auto-size the row-height in a datatable depending of the content? What I'm looking for is an adjustment of the row-height if a cell contains more than one line of information. For that the cells should wrap the content and display it as multi-line text (automatically or at least on user-action). Setting the $height property during table generation will not solve the problem.


  • Grab latest Webix package ( you need version 1.5 ), and try to do the same as in the next sample

  • edited April 2014

    Hi maksim,

    for me this only works if the data is included in the script as in the example. If you run the example with loading json data from external file, the multi-line sizing of the row cells fails. The correct sizing also fails if you adjust the column width manually (-> resizeColumn:true). "onColumnResize :webix.once(function(){this.adjustRowHeight("title", true);})" doesn't do it.

    Any hint to solve the problem?

  • Please check the attached sample

    the solution with onAfterLoad must trigger resizing after any data loading operation. Handler for onColumnResize will trigger row adjusting after column resizing.

  • Thank you,
    that works fine if there is only one column with long text.

    How do you handle multiple columns with long text?

  • Unfortunately there is no built in solution for such use-case

  • edited September 2017

    Hi Maksim,

    this modified adjustRowHeight function works fine for me:

    webix.extend(webix.ui.datatable, {
      myAdjustRowHeight:function(id, silent, rId){
        function processRow(that,obj){
          var h =  [that._settings.rowHeight], config;
          for(var i=0;i<id.length;i++){
            config = that.getColumnConfig(id[i]);
   = config.width+"px";
            d.innerHTML = that._getValue(obj, config, 0);
          obj.$height = Math.max.apply(null,h);
         if(typeof id == 'string') id=[id];
         var d = webix.html.create("DIV",{"class":
           "webix_table_cell webix_measure_size webix_cell"},"");
 = "height:1px; visibility:hidden;
                           top:0px; left:0px; overflow:hidden;";
              var obj = this.getItem(rId);
              }, this);
          d = webix.html.remove(d);
          if (!silent)

    and in the datatable definition (example from

        }, this);
      onDataUpdate:function(rId,data){  // called after cell update from editor

    The first argument in myAdjustRowHeight could be a string (->a single column id) or an array of column ids. The third one is optional and should be a valid row-Id. If set, only for this row the row-height will be adjusted.

    One important hint: This function doesn't work together with the minified version of webix (webix.js) provided in the download!

    But if you use webix_debug.js, it works fine, even if webix_debug.js is compressed with the tool from Dean Edwards (783kB -> 284kB). Works also if webix_debug is minified with UglifyJS (->464kB).
    But It may fail if the compression is done by a different tool!

    Have a nice day!

  • Looks interesting, we can include something similar in the next build
    Thanks for the shared code.

    By the way, to make above compatible with compressed code you need to replace commands starting from "_".
    "_settings" can be replaced with "config"
    "_getValue(obj, config,0)" can be replaced with "getText(,"

  • Hello, Maksim. May i ask you about next problem?

    i used your code for multiline text in cell and it works great, but one little thing is hurting me. When tabledata is loading, i see text "loading...". Its good. But after this, i see table without multilinetext, i cant press any controls, and after 3-5 second cells transform into multiline and all becomes good. How can i denied render of table before multiline script finish his work?

    Thanks a lot for answer

  • Can anyone help me - how to get Multiline header text in datatable.

  • edited April 2016

    Hello devs,

    I'm using the @gert solution with the @marksim update. It works like a charm and would be great to have this feature within the framework.


  • I am doing the same as @Nom4d3 now. @gert came up with a great solution. I was working on a something along the same lines, but hit I'm not a Javascript wizard like he is.

    @maksim I agree with the guys here, this would be a great feature to have in the framework by default (maybe as adjustRowHeightByColumns(array(), bool)?). It's not a cheap method, but not overly expensive, and borderline necessary for anyone using big dynamic datasets for datatables.

  • this works fine but If cell contains a button and button text is too long then it wont wrap. Any solution for this ?

Sign In or Register to comment.