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

CommandItem and RadGrid

4 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paulo
Top achievements
Rank 1
Paulo asked on 17 Feb 2014, 03:57 PM
I have a RadGrid and I need to add a button to clear all filters. I found the option to use CommandItem however the it does not work. I got an error "The script tag registered for type 'System.Web.UI.Page' and key has invalid characters outside of the script tags:".

My RadGrid is popupated with an 'OnNeedDataSource="RadGrid1_NeedDataSource" '. Do I need to give functionality to the refresh button? If so how can I set the functionality to the refresh button?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Feb 2014, 04:15 AM
Hi Paulo,

You can add a Button in the CommandItemTemplate and handle its click event to clear the filters:

ASPX:
<MasterTableView CommandItemDisplay="Top">
 <CommandItemTemplate>
  <asp:ImageButton ID="ClearFilter" runat="server" AlternateText="ClearFilter" OnClick="ClearFilter_Click". . />
 </CommandItemTemplate>

C#:
protected void ClearFilter_Click(object sender, ImageClickEventArgs e)
{
 foreach (GridColumn column in RadGrid1.MasterTableView.Columns)
 {
     column.CurrentFilterFunction = GridKnownFunction.NoFilter;
     column.CurrentFilterValue = String.Empty;
 }
 RadGrid1.MasterTableView.FilterExpression = String.Empty;
 RadGrid1.Rebind();
}

Thanks,
Princy
0
Paulo
Top achievements
Rank 1
answered on 18 Feb 2014, 11:56 AM
Hi Priny

thank you for your message. After I post my question I figured it out. Basically same solution. The only difference is to be able to handle the event I needed to add on the rad grid a onCommandItem="methodName". I am not in my computer right now but I am pretty sure that this is the radGrid attribute name.

thank you very much for your response. I appreciate it.
0
Paulo
Top achievements
Rank 1
answered on 18 Feb 2014, 02:13 PM
Princy

Quick question. What I have seen is that the CommandItems such add new value or refresh are placed on top of the grid. So if you have a paging set to top and bottom and also you have the commandItems the command items will be place on top of the top paging bar.
Is there a way to display the commandItems below the paging bar?
0
Eyup
Telerik team
answered on 20 Feb 2014, 12:11 PM
Hello Paulo,

I'm afraid changing the rendering structure of the grid is not supported. Although this requirement can be achieved using some custom javascript, jQuery and CSS, we highly suggest that you avoid such implementation since it may damage the grid client-side functionality.

I hope the clarification was helpful.

Regards,
Eyup
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Paulo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Paulo
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or