Jump to content

dbGrid Multi-Line Memo Column


fraxzi

Recommended Posts

On 5/4/2021 at 1:28 PM, Sherzod said:

Hello,

UniDBGrid -> Columns[xx] -> DisplayMemo = True ?

Hi @Sherzod,

I wish to limit the memo to 3 lines ... the 3rd line should display ellipsis "..." if memo is more than 2 lines ... (max line is 50 chars)

How can I accomplish?

 

Thanks in advance,

Frances

Link to comment
Share on other sites

Hello, can this help You:

https://sciter.com/forums/topic/how-to-text-overflowellipsis-in-textareareadonly/

use it on Your custom css file.

<!DOCTYPE html>
<html>
<head>
<style>

textarea {
  width: 200px;
  border: 1px solid;
  padding: 2px 5px;

  /*resize:none;*/

 /* BOTH of the following are required for text-overflow */
  white-space: nowrap;
  overflow: hidden;
}

.overflow-visible {
  white-space: initial;
}

.overflow-clip {
  text-overflow: clip;
}

.overflow-ellipsis {
  text-overflow: ellipsis;
}

.overflow-string {
  /* Not supported in most browsers,
     see the 'Browser compatibility' section below */
  text-overflow: " [..]";
}


</style>
</head>
<body>

 

<textarea id="w3review"  class="overflow-ellipsis" name="w3review" rows="4" cols="50">
   Nulla aliquet gravida nunc sit amet ultrices. Vestibulum ultricies mi eget feugiat aliquet
Curabitur placerat tellus vel pulvinar fringilla. Integer dignissim ut sem eget mollis.
Aliquam ac tortor in nunc dapibus blandit. Aliquam vehicula diam quis sem consequat
  </textarea>

</body>
</html>

 

and explanation in thishttps://stackoverflow.com/questions/40921849/text-overflow-ellipsis-not-work-on-textarea

аnd herehttps://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow

 

Link to comment
Share on other sites

21 hours ago, irigsoft said:

Hello, can this help You:

https://sciter.com/forums/topic/how-to-text-overflowellipsis-in-textareareadonly/

use it on Your custom css file.

<!DOCTYPE html>
<html>
<head>
<style>

textarea {
  width: 200px;
  border: 1px solid;
  padding: 2px 5px;

  /*resize:none;*/

 /* BOTH of the following are required for text-overflow */
  white-space: nowrap;
  overflow: hidden;
}

.overflow-visible {
  white-space: initial;
}

.overflow-clip {
  text-overflow: clip;
}

.overflow-ellipsis {
  text-overflow: ellipsis;
}

.overflow-string {
  /* Not supported in most browsers,
     see the 'Browser compatibility' section below */
  text-overflow: " [..]";
}


</style>
</head>
<body>

 

<textarea id="w3review"  class="overflow-ellipsis" name="w3review" rows="4" cols="50">
   Nulla aliquet gravida nunc sit amet ultrices. Vestibulum ultricies mi eget feugiat aliquet
Curabitur placerat tellus vel pulvinar fringilla. Integer dignissim ut sem eget mollis.
Aliquam ac tortor in nunc dapibus blandit. Aliquam vehicula diam quis sem consequat
  </textarea>

</body>
</html>

 

and explanation in thishttps://stackoverflow.com/questions/40921849/text-overflow-ellipsis-not-work-on-textarea

аnd herehttps://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow

 

Hi,

This is good for readonly (am I right?).. the memo column should be editable.

Thanks.

Link to comment
Share on other sites

Hi, 

My solution is:

1: Put this CSS in servermodule:

.x-p-memoww 
{
  word-wrap: break-word !important;
  white-space: pre-line;
  line-height: 1.2 !important;
  padding: 2 5 2 5; 
}

2. Create a new calculated field in your query (e.g. name it "TextMultilines").
3. use the DatasetCalcField event and put in this code: 

DataSet.FieldByName('TextMultilines').AsString:='<p class="x-p-memoww">' + DataSet.FieldByName('OriginField').AsString + '</p>';


4. set the property "AllowHTML" of the new field to true
5. use the new field in your grid

If it's absolutely necessary for you to limit the text to 3 line, you have to calculate the html by yourself.
In this case you can set aside the css stuff above and as part 3 you have to use something like that:
3. use the DatasetCalcField event and put in this code: 

DataSet.FieldByName('TextMultilines').AsString:=
'<p>' + copy(DataSet.FieldByName('OriginField').AsString,1,30)+'<b>'+ 
+ copy(DataSet.FieldByName('OriginField').AsString,31,30)+'<b>'+ 
+ copy(DataSet.FieldByName('OriginField').AsString,61,30)+'...'+ 
 '</p>';

Of course you have to improve this code to ensure, that words are not divided in the middle of the word. And you have to measure the available width in the grid.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...