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

Column Resizing with Fixed Width Filter Textboxes

1 Answer 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rhonda
Top achievements
Rank 1
Rhonda asked on 30 Jul 2012, 04:20 PM
I am having trouble when resizing columns. I think it has to do with setting the filtering textbox widths on item rendering, but, I have to do this or the filtering textboxes do not fit within the columns (see filterboxnotfixed.gif attached).

When the grid first appears the columns and filter row matchup with the data table columns (see before.gif attached), however, when I go to resize column 3 everything gets messy (see after.gif attached).

Do you have any suggestions on how to resize the filter textboxes when column resizing occurs?

protected void RadGridAggressiveMatches_ItemCreated(object sender, GridItemEventArgs e)

{

if (e.Item is GridFilteringItem)

{

GridFilteringItem filteringItem = e.Item as GridFilteringItem;

 //set dimensions for the filter textbox
TextBox box = filteringItem["Column1"].Controls[0] as TextBox;
box.Width = Unit.Pixel(50);

box = filteringItem["Column2"].Controls[0] as TextBox

box.Width = Unit.Pixel(50);

box = filteringItem["Column3"].Controls[0] as TextBox;

box.Width = Unit.Pixel(175);

box = filteringItem["Column4"].Controls[0] as TextBox;

box.Width = Unit.Pixel(175);

box = filteringItem["Column5"].Controls[0] as TextBox;

box.Width = Unit.Pixel(175);

box = filteringItem["Column6"].Controls[0] as TextBox;

box.Width = Unit.Pixel(175);

box = filteringItem["Column7"].Controls[0] as TextBox;

box.Width = Unit.Pixel(15);

box = filteringItem["Column8"].Controls[0] as TextBox;

box.Width = Unit.Pixel(45);

}

}

 
<telerik:RadGrid ID="RadGridAggressiveMatches" runat="server" Width="1100px" Height="250px" DataMember="Aggressive Members"

 GridLines="None"

 AllowSorting="True"

 ShowFooter="True"

 Skin="Office2007"

 AutoGenerateColumns="False"

 AllowFilteringByColumn="True"

 onitemcreated="RadGridAggressiveMatches_ItemCreated"

 onselectedindexchanged="RadGridAggressiveMatches_SelectedIndexChanged"

 onsortcommand="RadGridAggressiveMatches_SortCommand"

 onneeddatasource="RadGridAggressiveMatches_NeedDataSource" >

 <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" EnablePostBackOnRowClick="true">

 <Selecting AllowRowSelect="True" />  

 <Scrolling AllowScroll="true" />

 <Resizing AllowColumnResize="true" AllowRowResize="true" ResizeGridOnColumnResize="false" />

 </ClientSettings>

 <MasterTableView TableLayout="Fixed" AllowFilteringByColumn="true" >

 <Columns>

 <telerik:GridBoundColumn UniqueName="Column1" DataField="Column1" HeaderText="Column 1" DataType="System.Int32"

 SortExpression="Column1" AllowFiltering="true" AutoPostBackOnFilter="false">

 <HeaderStyle Width="75px" />

 <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"

 Font-Strikeout="False" Font-Underline="False" Wrap="False" />

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn UniqueName="Column2" DataField="Column2" HeaderText="Column 2" DataType="System.Int32" SortExpression="Column2">
<HeaderStyle Width="75px" />
<ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"

 Font-Strikeout="False" Font-Underline="False" Wrap="False" />

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn UniqueName="Column3" DataField="Column3" HeaderText="Column 3" DataType="System.String"

 SortExpression="Column3">

 <HeaderStyle Width="200px" />

 <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"

 Font-Strikeout="False" Font-Underline="False" Wrap="False" />

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn UniqueName="Column4" DataField="Column4" HeaderText="Column 4" DataType="System.String"

 SortExpression="Column4">

 <HeaderStyle Width="200px" />

 <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"

 Font-Strikeout="False" Font-Underline="False" Wrap="False" />

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn UniqueName="Column5" DataField="Column5" HeaderText="Column 5" DataType="System.String" SortExpression="Column5">

 <HeaderStyle Width="200px" />

 <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"

 Font-Strikeout="False" Font-Underline="False" Wrap="False" />

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn UniqueName="Column6" DataField="Column6" HeaderText="Column 6" DataType="System.String" SortExpression="Column6">

 <HeaderStyle Width="200px" />

 <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"

 Font-Strikeout="False" Font-Underline="False" Wrap="False" />

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn UniqueName="Column7" DataField="Column7" HeaderText="Col 7" DataType="System.Int32" SortExpression="Column7">

 <HeaderStyle Width="40px" />

 <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"

 Font-Strikeout="False" Font-Underline="False" Wrap="False" />

 </telerik:GridBoundColumn>

 <telerik:GridTemplateColumn UniqueName="Column8" HeaderText="Column 8" SortExpression="Column8">

 <HeaderStyle Width="70px" />

 <ItemTemplate>

 <asp:RadioButtonList ID="RadionButtonListDecision" runat="server" RepeatDirection="Vertical">

 <asp:ListItem Value="1" Text="Yes"></asp:ListItem>

 <asp:ListItem Value="2" Text="No"></asp:ListItem>

 </asp:RadioButtonList>

 </ItemTemplate>

 </telerik:GridTemplateColumn>

 </Columns>

 </MasterTableView>

 <FilterMenu Skin="Office2007" EnableTheming="True">

 <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 </FilterMenu>

 </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 01 Aug 2012, 01:56 PM
Hello Rhonda,

I am attaching a sample RadGrid web site implemented with the requested functionality. Please check out the attached application and try to make best avail out of it according to your specific scenario.

Regards,
Eyup
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.
Tags
Grid
Asked by
Rhonda
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or