This is a migrated thread and some comments may be shown as answers.

column expand when focus on cell

7 Answers 327 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jose
Top achievements
Rank 1
Jose asked on 03 Oct 2017, 06:17 AM

Hi,

Suppose If I have given fixed width for one column and overflow text will be hidden with ellipsis. I wanted to expand column to show full text when I focus on any cell of that particular column and when focus out it will back to old state(width). Could anyone please help me on this?

Thanks in Advance

7 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 03 Oct 2017, 01:54 PM
Hello Jose,

For the time being, the Grid does not provide this functionality out of the box.

To achieve a similar behavior, you could handle the change event of the Grid. In the event handler, save the current cell width and index in global variables. After that, use the autoFitColumn method to expand the column. On the next change event use these variables to restore the original width.
For example, check my testing Dojo: 
Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jose
Top achievements
Rank 1
answered on 05 Oct 2017, 06:29 AM

Hello Preslav,

Thank you so much for you suggestion. It helps me to implement the functionality.

Also I was trying to add some slide animation when it expand or collapse column using css property transition width for col element like transition:width .8s ease. Animation working fine on collapse but not on expand.

Do you have any suggestion on this.

Thanks again for your great help!

Regards,

Jose Abraham

0
Preslav
Telerik team
answered on 05 Oct 2017, 10:53 AM
Hello Jose,

This might be achieved by using the resize function from my last reply and the "scrollWidth" property of the selected cell instead of the autoFitColumn method.

For example, check the modified Dojo:
I hope this helps.


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jose
Top achievements
Rank 1
answered on 05 Oct 2017, 12:39 PM

Hi Preslav,

scrollWidth property gives me only selected cell width expansion. and when I try to click any other cell in the same index it is not effecting because of if condition. So when I remove if condition and clicked same index cells, its keep on increasing.

Could you please see on this. Actually first post example suits my requirement and only thing is animation required like recent example.

Thank you very much for quick response.

 

0
Jose
Top achievements
Rank 1
answered on 06 Oct 2017, 04:32 AM

Hello Preslav,

Is there any way to get autoFitColumn width? if yes, I think we can use resizeOldCol width as same autoFitColumn width and achieve the requirement.

Thanks again.

Jose Abraham

0
Accepted
Preslav
Telerik team
answered on 09 Oct 2017, 07:08 AM
Hi Jose,

I was not able to find a way to get the width from the autoFitColumn method. A possible approach, in this case, might be looping through the rows and saving the max cell scrollWidth and using it for the resizeOldCol function. For example:

for(var i = 0; i<rows.length; i++){
             var row = rows[i];
             var width = row.cells[cellIndex].scrollWidth;
              
             if(width>max){
               max = width;
             }
           }
           resizeOldCol(cellIndex, max);

Check the modified Dojo here: https://dojo.telerik.com/ODuBU/7 

Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jose
Top achievements
Rank 1
answered on 09 Oct 2017, 10:38 AM

Thank You so much Preslav. It works!!!

Tags
Grid
Asked by
Jose
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Jose
Top achievements
Rank 1
Share this question
or