Display wrapped text in a cell

1,374 views
Skip to first unread message

karypid

unread,
Apr 27, 2011, 3:51:10 PM4/27/11
to SlickGrid
Hello,

I've created a grid in which I would like to display "news items"
which have a title and some content. Unfortunately the text I put
inside the column refuses to wrap onto the next row, resulting in very
little text being visible (even though there is plenty of space
underneath: the row height is enough to allow 4-5 lines to be
displayed).

My formatter looks like this:

var articleFormatter = function(row, cell, value, columnDef,
dataContext) {
return "<div style=\'width: 400px;\'><h4><a href='/" +
dataContext["someField"]
+ "/staff/" + dataContext["id"] + "'>" + dataContext["title"]
+ "</a></h4>" + "<p style=\'width: 400px;\'>" +
dataContext["content"] + "</p></div>";
};

As you see, I've tried to set the width attribute to restrict the
column using both a <div> and <p> style. The grid's column width is
set to 480 as follows:

var columns = [{id:'date',width:
200,formatter:dateFormatter,cssClass:'cell-story'},{id:'article',width:
480,formatter:articleFormatter,cssClass:'cell-story'}];

How can I get SlickGrid to wrap the text?

karypid

unread,
Apr 27, 2011, 4:03:17 PM4/27/11
to SlickGrid
Got it: style="white-space: normal" did the trick.

var articleFormatter = function(row, cell, value, columnDef,
dataContext) {
return "<h4><a href='/" + dataContext["someField"] + "/
staff/"
+ dataContext["id"] + "'>" +
dataContext["title"] + "</a></h4>"
+ "<p style='white-space: normal'>" +
dataContext["content"] + "</p>";

Gaurav Rai

unread,
Mar 4, 2015, 8:20:49 AM3/4/15
to slic...@googlegroups.com, kar...@gmail.com
Did it help to dynamically change the row height according to the incoming data?
I got word wrap enabled but I don't want to fix it to unnecessary height as multi line data is not in every row, if you have any solution to that please help. 

Günter Zöchbauer

unread,
Mar 11, 2015, 3:44:04 AM3/11/15
to slic...@googlegroups.com, kar...@gmail.com
As far as I know different row heights are not supported in SlickGrid
Reply all
Reply to author
Forward
0 new messages