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

Individually format filters?

2 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
J
Top achievements
Rank 1
J asked on 23 Jan 2013, 04:13 PM
Is there a way to declaratively format individual filters? For instance, to have some align left, some align center, and each have different widths. I'd like to avoid a FilterTemplate, and ideally I'd like to do it in the markup, but if I have to, I'll just do it in the back end. Sample:

<telerik:RadGrid ID="RadGrid" runat="server" AutoGenerateColumns="False" AllowSorting="True"
            AllowFilteringByColumn="True">
  <ClientSettings AllowColumnsReorder="True">
    <Scrolling UseStaticHeaders="True" AllowScroll="True" SaveScrollPosition="True"
            ScrollHeight="500px"/>
  </ClientSettings>
             
  <GroupingSettings CaseSensitive="False"/>
 
  <MasterTableView>
    <Columns>
      <telerik:GridBoundColumn UniqueName="Name" DataField="Name" HeaderText="Name"
                        AutoPostBackOnFilter="True" HeaderStyle-Width="35%"
                        ItemStyle-HorizontalAlign="Left"/>
      <telerik:GridBoundColumn UniqueName="Common" DataField="Common" HeaderText="Common"
                        AutoPostBackOnFilter="True"
                        HeaderStyle-HorizontalAlign="Center"/>
    </Columns>
  </MasterTableView>
</telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 Jan 2013, 09:24 AM
Hi,

You can set styles by accessing the filtering item and set the width using FilterControlWidth.
aspx:
<telerik:GridBoundColumn DataField="OrderID" FilterControlWidth="20px" UniqueName="OrderID"</telerik:GridBoundColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
        if (e.Item is GridFilteringItem)
        {
            GridFilteringItem item = (GridFilteringItem)e.Item;
            TextBox txt = (TextBox)item["OrderID"].Controls[0];
            txt.CssClass = "filter";
         }
}
CSS:
.filter
{
    float:right !important;
}

Thanks,
Shinu
0
J
Top achievements
Rank 1
answered on 24 Jan 2013, 01:57 PM
Excellent, this will work. Thanks, Shinu.
Tags
Grid
Asked by
J
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
J
Top achievements
Rank 1
Share this question
or