Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by James Snyder on Jul 20, 2009 09:58
open dhtmlx forum
Column width shrinks

I'm having a strange situation where the column displays less data in a specific situation.

The setup for the grid is: (first column shows text, the second a button)
grdFavorites = new dhtmlXGridObject('grdFavorites_container');
grdFavorites.setHeader(",");
grdFavorites.setNoHeader(true);
grdFavorites.enableCollSpan(true);
grdFavorites.setInitWidths("203,1");
grdFavorites.setColAlign("left,right");
grdFavorites.setColTypes("ro,txt");
grdFavorites.init();


Standard loading of the grid: (This is fine, shown for eval to you)
var sStyle = "color:#81a032;font-family:Arial;font-weight:bold;font-size:9pt;height:15px;";
var iRow = (grdFavorites.getRowsNum() +1);
var sMousePointer = "setMousePointer(this);"
sRestaurant = "    " + objItem[0]
sImageOrderURL2 = "<img src='../images/Favorite_Order.jpg' onmouseover="+sMousePointer+" onclick='orderFav("+objItem[1]+");' alt='click to order' />"

grdFavorites.addRow(iRow,objItem[2]+','+[sImageBlankURL]);
grdFavorites.addRow((iRow +1),sRestaurant+','+[sImageOrderURL2]);
grdFavorites.setColspan(iRow,0,2);
iRow = (grdFavorites.getRowsNum() - 1);
grdFavorites.setRowTextStyle(iRow, sStyle);


However, when there are no "Favorites" mgmt wants to display a few lines
"There are no favorites for this location"
"To learn more about Favorites click here" (this will be a url)


When the favorites are loaded there can be easily 24 charactors of text visible. (Thanks to "setColspan) However when I run the following code I can only see "No favorites for th" - The rest is cut off, even with setColspan

grdFavorites.clearAll(true);
var sStyle = "color:#81a032;font-family:Arial;font-weight:bold;font-size:9pt;"
grdFavorites.addRow(1,'No favorites for this location,');
grdFavorites.setRowTextStyle(1, sStyle);
grdFavorites.setColspan(1,0,2);


Please let me know what the heck I am doing wrong.

Thanks,
James
Answer posted by dhxSupport on Jul 21, 2009 10:07
By default dhtmlGrid doesn't increase it's widht depending on the cell's value. After pasting new value to the cell you can adjust column's width using:
 mygrid.adjustColumnSize(0);//adjust first column size

Also you should use grdFavorites.clearAll(); instead of grdFavorites.clearAll(true);