I have RadGrids in my application that need the columns resized by
their content; however, I do not want to include header into
consideration for resize.
For example, in the grid below, the content of Contact Person Name is almost always empty. Using the code below, the Contact Person Name becomes as wide as it needs to be to fit the header in one single row. But I do not care about the header content, it can be split into multiple lines if need be. If all the 25 rows in a page is empty for this record, I'd rather the header be split into three lines (one per word) and have a small column.
I'm calling this function from the javascript pageLoad of all pages that contain grid.
Can this be achieved?
Also, sometimes if the grid is long (a lot of columns) it takes more than a few seconds for the page is load up. The screen goes white until the calculation is done and grid is displayed. How can I easily provide a message during this time?
For example, in the grid below, the content of Contact Person Name is almost always empty. Using the code below, the Contact Person Name becomes as wide as it needs to be to fit the header in one single row. But I do not care about the header content, it can be split into multiple lines if need be. If all the 25 rows in a page is empty for this record, I'd rather the header be split into three lines (one per word) and have a small column.
<telerik:RadGrid ID="rgCompany" runat="server" AutoGenerateColumns="false" EnableViewState="true" PageSize="25" AllowSorting="true" AllowMultiRowSelection="true" AllowCustomPaging="true" OnNeedDataSource="rgCompany_NeedDataSource" OnSortCommand="rgCompany_SortCommand" OnItemDataBound="rgCompany_ItemDataBound"> <PagerStyle Mode="NextPrevNumericAndAdvanced" Position="Bottom" AlwaysVisible="True" /> <ClientSettings EnableRowHoverStyle="true"> <Selecting AllowRowSelect="true"></Selecting> <Resizing AllowColumnResize="True" ResizeGridOnColumnResize="True" AllowResizeToFit="True"></Resizing> <ClientEvents OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" /> </ClientSettings> <MasterTableView> <telerik:GridBoundColumn UniqueName="Name" HeaderText="Company Name" DataField="CompanyName" /> <telerik:GridBoundColumn UniqueName="City" HeaderText="City" DataField="City" /> <telerik:GridBoundColumn UniqueName="State" HeaderText="State" DataField="State" /> <telerik:GridBoundColumn UniqueName="Zip" HeaderText="Zip" DataField="Zip" /> <telerik:GridBoundColumn UniqueName="Phone" HeaderText="Phone Number" DataField="PhoneNumber" /> <telerik:GridBoundColumn UniqueName="Contact" HeaderText="Contact Person Name" DataField="ContactName" /> </MasterTableView></telerik:RadGrid>I'm calling this function from the javascript pageLoad of all pages that contain grid.
function resizeGridToFitColumnContent (grid) { var masterTable = grid.get_masterTableView(); var columns = masterTable.get_columns(); for (var i = 0; i < columns.length; i++) { columns[i].resizeToFit(); }}Can this be achieved?
Also, sometimes if the grid is long (a lot of columns) it takes more than a few seconds for the page is load up. The screen goes white until the calculation is done and grid is displayed. How can I easily provide a message during this time?
