Show tooltip/help text on querybuilder dropdown

Hello,

Some of the values in the dropdown on my querybuilder columns exceeds the width of column and not displayed properly.

As you can see below complete label is not displayed.

Can we display some tooltip  with complete name or any other solution for this.

Please advise.

Capture.JPG

Thanks,

Sanjay


5 Replies

YA YuvanShankar Arunagiri Syncfusion Team June 23, 2022 05:27 AM UTC

Hi Sanjay,


We have validated your reported query and prepared the sample based on your requirement. We can achieve your requirement by using the fieldModel property of the query builder. Using the fieldModel property you can the width or set the default tooltip using the open event of the dropdown list.

Please refer the below code snippet and sample link.


[app.component.ts]:

fieldModel: DropDownListModel = { width: '300px', open: this.onOpen }

………………….

        onOpen(args) {

           var elem = document.getElementsByClassName('e-dropdownbase')[0].querySelectorAll('.e-list-item');

           for (var i = 0; i < elem.length; i++) {

               elem[i].title = elem[i].textContent;

           }

        }


Sample link: https://stackblitz.com/edit/angular-ltpkfb?file=app.component.ts


Could you please check the above code and get back to us, if you need any further assistance on this. 


Regards,

YuvanShankar A



SS Sanjay Singh June 23, 2022 03:23 PM UTC


Hello,


Thanks for the reply.


Above solution has partially solved my issue.


can we make the width of the column dynamic as per the length of the text.




YA YuvanShankar Arunagiri Syncfusion Team June 24, 2022 07:18 AM UTC

Hi Sanjay,


We have validated your reported query and prepared the sample based on your requirement. Please refer the below code snippet.

[app.component.ts]:

onOpen(args) {

           var widthArray = [];

           var data = this.listData;

           for (var i = 0; i < data.length; i++) {

                let font: string = "15px Roboto";

                let canvas: HTMLCanvasElement = document.createElement('canvas');

                let ctx: any = canvas.getContext("2d");

                ctx.font = font;

                var width = ctx.measureText(data[i].label).width;

                widthArray.push(width);

           }

           this.width = (Math.max(...widthArray) + 20) + 'px';

        }


Sample link: https://stackblitz.com/edit/angular-ltpkfb-uttenh?file=app.component.ts


Could you please check the above code and get back to us, if you need any further assistance on this. 


Regards,

YuvanShankar A



SK Sravan Kumar Moravaneni replied to YuvanShankar Arunagiri September 9, 2022 11:39 AM UTC

Hi  YuvanShankar, in the above mentioned code, you had used "this.width" property, But its not present in the .ts file or the .html file and so the width is not getting increased. So, can you please update the above code snippet and in the stackblitz also, so that it will be helpful. And also, if there is any solution for, to display a tooltip for that selected value in the input field like in the dropdown values, will also be helpful.

Regards,
Sravan Kumar



YA YuvanShankar Arunagiri Syncfusion Team September 12, 2022 12:22 PM UTC

Hi Sravan,


We have validated your reported query and prepared the sample based on your requirement. please refer the below code snippet and sample link. we can achieve your requirement by using the target property of the tooltip component. And regards “this.width” was property of the dropdown list component and in onOpen method we get only dropdown list instance(this) only. Please check/debug the onOpen method once again.

[app.component.ts]:

this.tooltip = new Tooltip({

          // default content of tooltip

          content: 'Loading...',

          // set target element to tooltip

          target: '.e-list-item, .e-rule-filter .e-input-group',

          // set position of tooltip

          position: 'TopCenter',

          // bind beforeRender event

          beforeRender: this.onBeforeRender.bind(this)

      });

      this.tooltip.appendTo('body');

 


Sample link: https://stackblitz.com/edit/angular-ltpkfb-uttenh?file=app.component.ts

Could you please check with the above code and get back to us, if you need any further assistance on this.


Regards,

YuvanShankar A


Loader.
Up arrow icon