I'm developing a web application and I'm using a lot of grid. I'm trying to avoid having a lot of customization for each one of them. I'd like that the grid set each column's initial width based on the content. I. e.:
Short name NameJF John FooAB Ana Bar
All values for 'Short name' are 2 chars long, and the longest value for 'Name' is 'John Foo' with 8 chars. So in this case, the grid should set 'Short name' column's width to 20%, and 'Name' column's width to 80%.
In case this functionality does not exisist, could you give me some clues so I know where to start building it?
Thanks,Diego
I've just tried. I couldn't get it working.
I keep getting the error: Can't get property 'getBoundingClientRect' from null or undefined.
Based on what I could see in the min version, this happens when the real width is calculated: col.width=Math.ceil($firstRowCells[index].getBoundingClientRect().width);
I've a grid width 4 columns, the first of them is hidden. The error is when it is calculating the last width (for the 4th column) and its because index is 3 and $firstRowCells's length is also 3.
Edit:
I believe this is related to the versions I'm using. I've made this fiddle (replace the *** in the URL with p a s k a without the spaces) which works fine but I use the same code in my environment and it fails. Here are the details:
Hi intecomp,
To enable auto sizing of the column you need to set its width to “*”.
Let me know if you have any further questions!
Kind regards,
Petko Zhekov
Software Developer
Hello Petko, thanks for the update on this.
I've downloaded and installed the new version (v 15.1.20151.2112 as I can see in infragistics.core.js). However I still can't get the behavior I'm looking for.
I've tried both auto-generating the columns and setting up the columns array (this is the one I really need). In the second case I didn't set any width manually for each column. Anyway, the columns are always sized proportionally to the total amount of columns, and not to their content.
Am I doing something wrong?
Hello intecomp,
Your development issue has been addressed in our latest service release which is available for download.
Please let me know if you come across any further issues with the new service release or if you have any further questions .
Kind Regards,
Infragistics, Inc.
Hello,
We already have this behavior logged in our internal tracking system with a Development ID of 193267. A support case is created on your behalf with number CAS-156270-Z4K0Q0, so that you can be notified when the issue is fixed.
You can find your active cases under Account - Support Activity in our website. Select your ticket and go to Development Issues tab to view the status of related bugs.
Let me know if I may be of further assistance.