3 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 23 Feb 2012, 12:23 PM
0
Mark
Top achievements
Rank 1
answered on 23 Feb 2012, 01:55 PM
thanks
but was seeking something more dynamic rather than user intereaction.
for example a simple grid with say 3 text columns but 10 numeric columns, id like the numeric columns to be smaller width, i can of course do this by checking each column name and setting width but hoped there might be a more efficient way.
but was seeking something more dynamic rather than user intereaction.
for example a simple grid with say 3 text columns but 10 numeric columns, id like the numeric columns to be smaller width, i can of course do this by checking each column name and setting width but hoped there might be a more efficient way.
0
Hi Mark,
RadGrid provides the so-called "best-fit" size for grid columns. This client-side functionality calculates the best-fit size of the grid columns based on their content. You can use it to render your grid in an optimal layout. However, as this is a client-side feature, you need to use some javascript to find all column on the client and resize them to their best fit. This needs to happen when the grid loads initially. Try the following javascript on your page (RadGrid1 is the server-side ID of the RadGrid control):
function
pageLoad() {
var
grid = $find(
"<%= RadGrid1.ClientID %>"
);
var
columns = grid.get_masterTableView().get_columns();
for
(
var
i = 0; i < columns.length; i++) {
columns[i].resizeToFit();
}
}
Sample test page is attached to demonstrate the working example.
Veli
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.