Jump to content

How to setting clientside TunimMemo autoHeight to get width and height with resize event?


newsanti

Recommended Posts

30 minutes ago, newsanti said:

How to setting clientside TunimMemo autoHeight to get width and height with resize event?

Hello,

Your question regarding the resize event is not very clear.

I guess if you are using client-side alignment, you can use layouts.

Link to comment
Share on other sites

1 hour ago, newsanti said:

I want TunimMemo to auto height with textlength.

This approach may help you:

UnimMemo1.ClientEvents.UniEvents ->

function beforeInit(sender, config)
{
    config.listeners = {
        keyup: function(textarea) {
            var inputEl = textarea.inputElement,
                textHeight = inputEl.dom.scrollHeight;

            textarea.setHeight(textHeight);
        }
    }
}

 

  • Thanks 1
Link to comment
Share on other sites

7 hours ago, Sherzod said:

This approach may help you:

UnimMemo1.ClientEvents.UniEvents ->

function beforeInit(sender, config)
{
    config.listeners = {
        keyup: function(textarea) {
            var inputEl = textarea.inputElement,
                textHeight = inputEl.dom.scrollHeight;

            textarea.setHeight(textHeight);
        }
    }
}

 

function beforeInit(sender, config)
{
    config.listeners = {
        keyup: function(textarea) {
            var inputEl = textarea.inputElement;
                textHeight = inputEl.dom.scrollHeight;
            if textarea.getValue()=='' then         //Check when backspace and empty
              textHeight=30;

            textarea.setHeight(textHeight);
        }
    }
}

If add condition when backspace not work?  How to fix it?

Link to comment
Share on other sites

1 minute ago, newsanti said:

If add condition when backspace not work?  How to fix it?

?

 

if textarea.getValue()=='' then         //Check when backspace and empty
              textHeight=30;

 

if (textarea.getValue() == '') {
    textHeight=30;
}

 

  • Like 1
Link to comment
Share on other sites

5 minutes ago, Sherzod said:

?

 

if textarea.getValue()=='' then         //Check when backspace and empty
              textHeight=30;

 

if (textarea.getValue() == '') {
    textHeight=30;
}

 

function beforeInit(sender, config)
{
    config.listeners = {
        keyup: function(textarea) {
               var inputEl = textarea.inputElement;
                textHeight = inputEl.dom.scrollHeight;
               if (textarea.getValue() == '') {
                 textHeight=30;
               }
            textarea.setHeight(textHeight);
            if (textHeight != textarea.getHeight()) then {       //check to fire resize not work ? How to fix?
              ajaxRequest(sender,'_resize',{H: textHeight});
            }  
        }
    }
}

Link to comment
Share on other sites

37 minutes ago, newsanti said:

Thanks.

 

37 minutes ago, newsanti said:

Thanks.

Finally ..My code completed. 

function beforeInit(sender, config)
{
    config.listeners = {
        keyup: function(textarea) {
               var inputEl = textarea.inputElement;
               textHeight = inputEl.dom.scrollHeight;

               if (textarea.getValue() == '') {
                 textHeight=35;
               } 
            if (textHeight != textarea.getHeight()) {
              var H1 = textHeight;
              var H2 = textarea.getHeight();
              if (H1<=35*4) { textarea.setHeight(textHeight); }
              ajaxRequest(sender,'_resize',{newH: H1, oldH: H2});
            }
        }
    }
}

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

On 2/22/2024 at 11:15 AM, Sherzod said:

This approach may help you:

UnimMemo1.ClientEvents.UniEvents ->

function beforeInit(sender, config)
{
    config.listeners = {
        keyup: function(textarea) {
            var inputEl = textarea.inputElement,
                textHeight = inputEl.dom.scrollHeight;

            textarea.setHeight(textHeight);
        }
    }
}

 

procedure TMainmForm.UnimFormShow(Sender: TObject);
begin
  UnimMemo1.Clear;
  UnimMemo1.Lines.Add('TestLine1');
  UnimMemo1.Lines.Add('TestLine2');
  UnimMemo1.Lines.Add('TestLine3');
  UnimMemo1.Lines.Add('TestLine4');
  UnimMemo1.Lines.Add('TestLine5');
  UnimMemo1.Lines.Add('TestLine6');
  UnimMemo1.Lines.Add('TestLine7');
  UnimMemo1.Lines.Add('TestLine8');
end;

If fill data by code .. How to change height of textarea?
This code change only keyup event.

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...