I am binding all the columns of the dataSource using AutoGenerateColumns="true" property. Width of the header cell is default width of GridView column.
The purpose is to create a decent table layout, with minimal work on markup. Thus trying to skip binding each column explicitly.
Is there a way to achieve this in GridView i.e. to set width of column based on content of the cell. i.e.
<tr><th>DummyHeaderContainingMoreLength</tr></th>
<tr><td>cellContent</tr></td>
Can I obtain width of the cell as lengthof(cellContent), let the header float or truncate.
Set width="100%". This will do.
Related
I want to manual set column(head and body) size(width, height).
I tired to set style but not work and find all document not found about this.
DataGrid Component
DataGrid set width size not work
Setting the column width:
<clr-dg-column [style.width.px]=“200”>my column</clr-dg-column>
This will also set width for all column cells.
To control height and width you can either put the datagrid inside a container with a set height/width.
After i tired use set style on template(html)
my column
I have other problem when use follow Server Driven(https://clarity.design/documentation/datagrid/server-driven)
When next pagging each column length adjusted according to data i found overlap column
Data overlap column
and when binding long length data i found header separate column incorrect
header wrong separate column
My solution i think i have to loop for looking longest length and setting style width and writing logic in to typescript.
Have any solution easy way please suggest me.
I have gridview like picture below.
I need to freeze header of my gridview and a cell. When I scroll the page vertically, the header's position fix on top. When I scroll horizontally, the specific column freeze and become the first column like below
How can I do that?
Simplest solution: create a duplicate copy of the the grid, lets call it grid2.
Right after setting the datasource of the original grid, set the datasource of grid2 to originalgrid.Rows[0]; then bind the grid2
grid2.dataSource = OriginalGrid.Rows[0]
grid2.Bind()
I hava a gridView with different width of columns (15%,17% ect...).
Some cell contain a very long text- in order to make all text seen and not truncated I used table-layout= fixed in the property "Style" of the gridview.
The problem is- the fixed property makes all columns' width to be equal and not what I defined.
How can I fix this?
<asp:GridView id="grd" style="width:100%"></asp:GridView>
I have a number of GridView controls that I need to position side-by-side on a page. For example a GridView containing a list of items in a shopping basket, and a number of GridViews to the side showing pricing from a number of suppliers.
The columns are fixed width in the first GridView - meaning that the row height is variable depending on the amount of text.
So, the question is this - is there any way to discover the individual row heights of the first data-bound GridView such that I can alter the other GridViews to correctly align?
The Row.Height property of the grid after databinding is empty as the height has not been explicity set.
thanks!
I don't know of any way to do this in .Net, you can use javascript, maybe set a .Net hidden field on load if you need it in code behind :
var h = document.getElementsByTagName('td')[0].offsetHeight;
Keep in mind this height will also include any cell padding or spacing you have set. Also, this assumes you're not explicitly setting the height in CSS which based on your question I assume you are not.
I have a gridview control that can get loaded with multiple pages worth of data. When I switch pages, the columns widths will change to accommodate the largest value in the column for that page.
If possible, I would like to set the widths of each column to the widest necessary width for the entire dataset.
You can set the ItemStyle-Width property on each TemplateField, BoundField, etc. in your gridview to whatever you want. That should hold across paging. You will want to either not set the gridview width, or be sure you don't use a percentage if you do.
If you want to figure this out dynamically, you will have to examine your data first, before binding your grid, figure out the width that you want, then bind your gird and dynamically set the ItemStyle-Width in the RowDataBound event of the gridview.
Tring things, in the edit colum menu of your grid you should try the auto size mode, I configure my to cell and it work pretty well for my needs..
This is available when you are not autogenerating the columns.
Try it.