Page 1 of 1

How-to limit # of row in textarea in table view with vertical scroll

Posted: 2015-06-26 05:49
by wplim
I have a table with many columns to be displayed in table view.
However, one of the text field contains quite a bit text which dictates the height of each row.
Is there a way to limit the height of the textarea say max. of 5 lines and shows a vertical scroll bar if text is more than 5 lines?

WP

Re: How-to limit # of row in textarea in table view with vertical scroll

Posted: 2015-06-26 07:50
by wplim
Here's my solution after a few trial and error with Appgini tutorial on "Customizing the data displayed in the table view"
http://bigprof.com/appgini/tips-and-tut ... eview-data

In my case, table is document, field is description.
The idea is to add a div layer over the description - <div style="max-height: 100px; overflow: auto;">description text</div>

Hope this will help other user.

Code: Select all

	function document_init(&$options, $memberInfo, &$args){
			// get the original fields array
			$oldFields = $options->QueryFieldsTV;
			
			// loop through all fields
			foreach($oldFields as $field => $title){
				// find the field that we need to customize
				if($field == '`document`.`description`'){
					// apply custom SQL formatting to the field
					$modField = "CONCAT('<div style=\"max-height: 100px; overflow:auto;\">',`document`.`description`,'</div/>')";
					$newFields[$modField] = $title;
				}else{
					// for other fields, keep them unchanged
					$newFields[$field] = $title;
				}
			}
			
			// now apply the modified fields
			$options->QueryFieldsTV = $newFields;
		return TRUE;
	}