I have a need similar to this one:
http://www.telerik.com/community/forums/aspnet-ajax/grid/set-customfiltercolumn-currentfilterfunction.aspx
I have a grid with filter columns using the default options (less a few I deleted in code behind).
Suppose the user selects a filter option such as "greater than". Afterward, if the user clears the filter box and then clicks the filter button, the user expects to invoke the "no filter" option. But it does not work. Instead the user must click the "no filter" option.
How can we cause the "no filter" option to be invoked if the user clears the filter box and then clicks the filter button?
Steve
I have a situation where depending on other controls on the page, I want to hide or show two different columns in a RadGrid. Unfortunately, I'm having trouble getting this to work.
The grid is being bound client-side to an ASP.NET AJAX web service. When the grid is being databound (i.e. in its ClientEvents-OnDataBinding event or in its ClientEvents-OnDataBound event [I've tried both, same results]) I use a loop like the following to hide or show the appropriate column:
| var view = g_grdProjects.get_masterTableView(); |
| for (var i = 0; i < view.get_columns().length; ++i) |
| { |
| if (view.get_columns()[i].get_uniqueName() == "Project.ProjectStageDate") |
| { |
| if (projectType == 'Closed') |
| view.showColumn(i); |
| else |
| view.hideColumn(i); |
| } |
| if (view.get_columns()[i].get_uniqueName() == "Project.Stage") |
| { |
| if (projectType == 'Closed') |
| view.hideColumn(i); |
| else |
| view.showColumn(i); |
| } |
| } |
This works as expected; however, when I use this code, posting back the page (which is required at some points) results in the following error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Web.UI.RadGrid.LoadClientState(Dictionary`2 clientState) +4232
Telerik.Web.UI.RadCompositeDataBoundControl.LoadPostData(String postDataKey, NameValueCollection postCollection) +149
Telerik.Web.UI.RadCompositeDataBoundControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +13
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +8905944
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +878
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
I've tried replacing the calls to showColumn and hideColumn with calls to the column's set_visible() method instead; that resolves the postback issue but results in incorrect behavior (the columns hide fine, but calling set_visible(true) does not show the columns, so they remain hidden forever).
Is there a way to use showColumn()/hideColumn() and keep the ability to post back when necessary?
| <script language="javascript" type="text/javascript"> |
| function ColumnResized(sender, eventArgs) |
| { |
| var columnIndex = eventArgs.get_gridColumn().get_element().cellIndex; |
| var newWidth = eventArgs.get_gridColumn().get_element().offsetWidth; |
| $("#<%= txtIndex.ClientID %>").val(columnIndex); |
| $("#<%= txtWidth.ClientID %>").val(newWidth); |
| } |
| </script> |
| <telerik:RadGrid ID="radGrid" runat="server" ShowHeader="true" Width="100%" GridLines="Both"> |
| <ClientSettings> |
| <Resizing AllowColumnResize="true" AllowRowResize="false" ResizeGridOnColumnResize="false" EnableRealTimeResize="true" /> |
| <ClientEvents OnColumnResized="ColumnResized" OnColumnResizing="ColumnResizing" /> |
| </ClientSettings> |
| <HeaderStyle HorizontalAlign="center" /> |
| <ItemStyle HorizontalAlign="center" /> |
| </telerik:RadGrid> |
protected void rgFormFields_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == "Cancel")
{
e.Canceled =
true;
rgFormFields.MasterTableView.ClearEditItems();
rgFormFields.Rebind();
}
else if (e.CommandName == "Update")
{
Update(e);
e.Canceled =
true;
rgFormFields.MasterTableView.ClearEditItems();
rgFormFields.Rebind();
}
else if (e.CommandName == "PerformInsert")
{
//bAddNewFormField_Click(source, e);
Insert(e);
e.Canceled =
true;
rgFormFields.MasterTableView.ClearEditItems();
rgFormFields.Rebind();
}
}
Anyhelp would be greatly appreciated.
Thanks,
Jonathan
| rsz_column.DockedPaneId = ""; |