Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by SFGolfer on Apr 28, 2009 08:07
open dhtmlx forum
Limit number of characters being shown (not entered)

Using gridx, is there a method of limiting the number of characters being shown?

Example usage:

Grid View
-----------

The content is wider than a column width set to 150px. The user canl see something like:

Now is the time for all good men to come...

grid.enableMultiline is not being used in the grid view.


Details Screen
-----------------

The user can then click on a "details" link which opens a new page and the full detail is shown from the selected row. The user will then see the full content:

Now is the time for all good men to come to the aid of their country.

grid.enableMultiline is being used in the details screen.


Objective
------------

To limit the number of characters shown (50) in the grid view and add "..." at the end to let the user know there is more content.
Answer posted by dhxSupport on Apr 28, 2009 09:50

Unfortunately dhtmlxGrid hasn't appropriate method. But you can do that programically:

mygrid.loadXML("grid.xml",function(){
  mygrid.forEachRow(function(id){
  value=mygrid.cellById(id,2).getValue()
  if (value.length>3) {
  value=value.slice(0,3);
  mygrid.cellById(id,2).setValue(value);
  }
  });
  });

If you have a lot of rows in your grid using such code can decrease loading perfomance. In such case better to implement custom eXcell type. Please see more information here http://www.dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Custom_excell_creation.html#grid_cexc