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

how write filtering for templatecolumns

5 Answers 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peyman
Top achievements
Rank 1
Peyman asked on 07 Nov 2011, 05:59 PM
hi dear telerik admin : 
i have two GridTemplateColumn in my RadGrid That Regular filtering on them has error and it seems we should change them! 
those GridTemplateColumns are like below : 
<telerik:GridTemplateColumn FilterControlAltText="Filter Online column" HeaderText="Online"
    UniqueName="Online">
    <ItemTemplate>
        <asp:CheckBox ID="chkOnline" runat="server" Checked='<%# CheckForOnline(Eval("ID")) %>'
            Enabled="False" />
    </ItemTemplate>
    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
</telerik:GridTemplateColumn>

and the other one :

<telerik:GridTemplateColumn FilterControlAltText="Filter FileSize column" HeaderText="FileSize"
    UniqueName="FileSize" Visible="False">
    <ItemTemplate>
        <asp:Label ID="lblFileSize" runat="server" Text='<%# Eval("FileSize") %>'></asp:Label>
    </ItemTemplate>
    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn FilterControlAltText="Filter FileSizeChange column" HeaderText="FileSize"
    UniqueName="FileSizeChange">
    <ItemTemplate>
        <asp:Label ID="lblFileSizeChange" runat="server" Text='<%# ChangeFileSize(Eval("FileSize")) %>'></asp:Label>
    </ItemTemplate>
    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridTemplateColumn>
as you seeFileSize TemplateColumn is disable and i am using FileSizeChange instead! 
FileSize string is like (213435) -> this number shows us bytes!
and FileSizeChange is like (231 MB)!
how can i write filtering for both Online and FileSizeChange ? 

thanks in advance

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 08 Nov 2011, 04:09 AM
Hello Peyman,

You can take a look into the following documentation.
Implementing Filtering for Template/Custom Columns

Thanks,
Princy.
0
Peyman
Top achievements
Rank 1
answered on 08 Nov 2011, 04:54 PM
dear princy hi,
i checked that link , but still have problems!
my first TemplateColumn has a checkBox inside that gets it's checked from code behind.
so i can not introduce this TemplateColumn DataField="Online" like that documentation.
so what can i do about that filtering?
it's c# code is like this : 
protected bool CheckForOnline(object User_ID)
{
    bool Situation;
    DataSet dsOnlineUsers = DataLayer.OnlineUsers.SelectRow_By_UserID_Latest(int.Parse(User_ID.ToString()));
 
    if (dsOnlineUsers.Tables["OnlineUsers"].Rows.Count > 0)
    {
        DataRow drOnlineUsers = dsOnlineUsers.Tables["OnlineUsers"].Rows[0];
 
        Situation = (bool)drOnlineUsers["Online"];
    }
    else
    {
        Situation = false;
    }
    return Situation;
}

and let me some explain about TemplateColumn  #2 (FileSizeChange)
this column uses FileSize TemplateColumn for filling itself.
i do n't want regular FileSize TemplateColumn So I diabled it!
and FileSizeChange  TemplateColumn codes are like below :
protected string ChangeFileSize(object FileSize)
{
    string FileSize_ = ConvertBytes.ToFileSize(long.Parse(FileSize.ToString()));//Returns Something Like 234 MB
    return FileSize_;
}

so New FileSize Have A different format and we can't introduce it's column DataField="FileSize"
would you plz learn me how can write filtering for these two TemplateColumn ?
would be appreciate for help!
best regards
0
Pavlina
Telerik team
answered on 14 Nov 2011, 10:13 AM
Hello Peyman,

For more information on this, please refer to the following code library submission. You can alter the logic according to your requirement:
http://www.telerik.com/community/code-library/aspnet-ajax/grid/individual-filtering-and-sorting-for-quot-sub-columns-quot-in-template-column.aspx

Regards,
Pavlina
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
0
Peyman
Top achievements
Rank 1
answered on 14 Nov 2011, 01:55 PM
thanks for answer,
but in those examples we do n't have any check box for filtering.
besides i want to use regular telerik filtering items in filtering drop down.
would you please give me some codes about my situations?

would be appreciate for help
0
Pavlina
Telerik team
answered on 17 Nov 2011, 02:26 PM
Hello Peyman,

Please refer to the Multi-Selection RadComboBox for filtering grid code library which shows how you could use Multi-Selection RadComboBox (with checkboxes in ItemTemplate) in the FilterTemplate of RadGrid.

All the best,
Pavlina
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
Peyman
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Peyman
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or