Home › Forums › Guriddo Suito PHP › Set rowHeight with wrap
I have a table that has one column of text that can be up to 2048 characters in length. Is there a way to set the row height to say, 5 rows and enable the text to wrap within the cell?
Hello,
The solution you requested require to add html content to your data.
This is tested and works as per your requirement:
Add the following style definition:
1 2 3 4 5 6 7 8 9 10 |
<style> .ui-jqgrid .ui-jqgrid-btable tbody tr.jqgrow td { white-space: normal !important; height: auto; } .mylongdata { height:90px; overflow-y:auto; } </style> |
after the jqgrid css.
Your long data when comes from the server or local array enclose in div tag with class mylongdata
so it look like:
1 |
<div class='mylongdata'>...your data here ...</div> |
You can adjust your height in mylongdata depending on your needs.
or simple use cell formatter to analyse its length and enclose it in that div with the class
If you have difficulties with using cell formatter, please let us know.
Kind Regards,
Will
Guriddo Support Team
Hi Will:
I implemented the changes but I am getting an error. Here is my index.php file:
[code lang=”php”]
<code>&amp;lt;?php</code>
<code>session_start();</code>
<code>?&amp;gt;;</code>
<code>&amp;lt;!DOCTYPE html&amp;gt;</code>
<code>&amp;lt;html&amp;gt;</code>
<code>&amp;lt;head&amp;gt;</code>
<code>&amp;lt;title&amp;gt;Contact Notes&amp;lt;/title&amp;gt;</code>
<code>&amp;lt;link rel="stylesheet" type="text/css" media="screen" href="/jqSuite/css/jquery-ui.css" /&amp;gt;</code>
<code>&amp;lt;link rel="stylesheet" type="text/css" media="screen" href="/jqSuite/css/trirand/ui.jqgrid.css" /&amp;gt;</code>
<code>&amp;lt;link rel="stylesheet" type="text/css" media="screen" href="/jqSuite/css/ui.multiselect.css" /&amp;gt;</code>
<code>&amp;lt;style type="text"&amp;gt;</code>
<code>html, body {</code>
<code>margin: 0; /* Remove body margin/padding */</code>
<code>padding: 0;</code>
<code>overflow: hidden; /* Remove scroll bars on browser window */</code>
<code>font-size: 100%;</code>
<code>}</code>
<code>.ui-jqgrid {</code>
<code>font-size: 14px;</code>
<code>}</code>
<code>.ui-jqgrid .ui-jqgrid-btable tbody tr.jqgrow td {</code>
<code>white-space: normal !important;</code>
<code>height: auto;</code>
<code>}</code>
<code>.mylongdata {</code>
<code>height: 90px;</code>
<code>overflow-y: auto;</code>
<code>}</code>
<code>&amp;lt;/style&amp;gt;</code>
<code>&amp;lt;script src="/jqSuite/js/jquery.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;</code>
<code>&amp;lt;script src="/jqSuite/js/trirand/i18n/grid.locale-en.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;</code>
<code>&amp;lt;script src="/jqSuite/js/trirand/jquery.jqGrid.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;</code>
<code>&amp;lt;script type="text/javascript"&amp;gt;</code>
<code>$.jgrid.no_legacy_api = true;</code>
<code>$.jgrid.useJSON = true;</code>
<code>$.jgrid.defaults.width = "700";</code>
<code>&amp;lt;/script&amp;gt;</code>
<code>&amp;lt;script src="/jqSuite/js/jquery-ui.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;</code>
<code>&amp;lt;/head&amp;gt;</code>
<code>&amp;lt;body&amp;gt;</code>
<code><div></code>
<code>&amp;lt;?php include ("tblLandOwners.php"); ?&amp;gt;</code>
<code></div></code>
<code>&amp;lt;/body&amp;gt;</code>
<code>&amp;lt;/html&amp;gt;</code>
[/code]
In my grid.php file I added the following:
[code lang=”php”]
// Set the url from where we obtain the data
$grid-&amp;gt;setUrl(‘tblLandOwners.php’);
// Change some property of the field(s)
$grid-&amp;gt;setColProperty("ContactDate", array("label"=&amp;gt;"Contact Date","editrules"=&amp;gt;array("required"=&amp;gt;true),"datefmt"=&amp;gt;’M jS, Y’,"formatter"=&amp;gt;"date","searchoptions"=&amp;gt;array("sopt"=&amp;gt;array("eq","ne","le","lt","ge","gt")),"formatoptions"=&amp;gt;array("srcformat"=&amp;gt;"Y-m-d H:i:s","newformat"=&amp;gt;"M jS, Y")));
$grid-&amp;gt;setColProperty("ContactNoteID", array("editable"=&amp;gt;false,"hidden"=&amp;gt;true));
$grid-&amp;gt;setColProperty("LandOwnerID", array("label"=&amp;gt;"LandOwner","width"=&amp;gt;"200", "searchoptions"=&amp;gt;array("sopt"=&amp;gt;array(‘cn’,’bw’,’bn’,’nc’)),"editrules"=&amp;gt;array("required"=&amp;gt;true)));
$grid-&amp;gt;setColProperty("ContactNote", array("label"=&amp;gt;"Contact Note","width"=&amp;gt;"200", "searchoptions"=&amp;gt;array("sopt"=&amp;gt;array(‘cn’,’bw’,’bn’,’nc’)),"edittype"=&amp;gt;"textarea", "editoptions"=&amp;gt;array("rows"=&amp;gt;5, "cols"=&amp;gt;80),"editrules"=&amp;gt;array("required"=&amp;gt;true)));
$grid-&amp;gt;setColProperty("ContactMode", array("lable"=&amp;gt;"Contact Mode","editrules"=&amp;gt;array("required"=&amp;gt;true)));
$grid-&amp;gt;setColProperty("ContactedBy", array("label"=&amp;gt;"Contacted By","width"=&amp;gt;"200", "searchoptions"=&amp;gt;array("sopt"=&amp;gt;array(‘cn’,’bw’,’bn’,’nc’)),"editrules"=&amp;gt;array("required"=&amp;gt;true)));
$grid-&amp;gt;setColProperty("NextStep", array("width"=&amp;gt;"200", "searchoptions"=&amp;gt;array("sopt"=&amp;gt;array(‘cn’,’bw’,’bn’,’nc’)),"edittype"=&amp;gt;"textarea","editoptions"=&amp;gt;array("rows"=&amp;gt;5, "cols"=&amp;gt;80)));
$myformat = &amp;lt;&amp;lt;&amp;lt;WR
function MyFormatter(cellValue, options, rowdata){
var cellHtml = ‘<div class="mylongdata">’ + cellValue + ‘</div>’;
return cellHtml;
}
WR;
$grid-&amp;gt;setJSCode($myformat);
$grid-&amp;gt;setColProperty("ContactNote", array(‘formatter’=&amp;gt;’js:MyFormatter’));[/code]
The error is reported in the developer console:
[code lang=”javascript”]
Uncaught ReferenceError: MyFormatter is not defined
at HTMLDocument.&amp;lt;anonymous&amp;gt; ((index):39:6647)
at j (jquery.min.js:2:26860)
at Object.fireWith [as resolveWith] (jquery.min.js:2:27673)
at Function.ready (jquery.min.js:2:29467)
at HTMLDocument.I (jquery.min.js:2:29658)
[/code]
Ken
What is the secret to formatting code like you did in your post above? I did it once years ago and now can’t for the life of me figure out how to do it.
Can you post a sticky post somewhere with instructions on how to post things like that in this forum?
Hello,
I have simulated some long text in order to show you the solution.
Here is the demo code
Kind Regards,
Will
Guriddo Support Team
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top